<!DOCTYPE html> <html class=itcauecng data-theme=light data-rh=data-theme style lang=zh><!--
 Page saved with SingleFile 
 url: https://zhuanlan.zhihu.com/p/75629282 
 saved date: Wed Dec 14 2022 09:17:36 GMT+0800 (中国标准时间)
--><meta charset=utf-8><title>《快速掌握PyQt5》第二十章 列表视图、树形视图、表格视图 - 知乎</title><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1"><meta name=renderer content=webkit><meta name=force-rendering content=webkit><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=google-site-verification content=FTeR0c8arOPKh8c5DYh_9uu98_zJbaWw53J-Sch9MTg><meta data-rh=true name=keywords content=PyQt,PyQt5,Python><meta data-rh=true name=description content=在前一张所讲的列表控件QListWidget，树形控件QTreeWidget和表格控件QTableWidget是基于项(item-based)的控件，它们分别与QListWidgetItem，QTreeWidgetItem以及QTableWidgetItem一起使用。在基于项的控件中，数据…><meta data-rh=true property=og:title content="《快速掌握PyQt5》第二十章 列表视图、树形视图、表格视图"><meta data-rh=true property=og:url content=https://zhuanlan.zhihu.com/p/75629282><meta data-rh=true property=og:description content=在前一张所讲的列表控件QListWidget，树形控件QTreeWidget和表格控件QTableWidget是基于项(item-based)的控件，它们分别与QListWidgetItem，QTreeWidgetItem以及QTableWidgetItem一起使用。在基于项的控件中，数据…><meta data-rh=true property=og:image content="https://pic1.zhimg.com/v2-23a56248e4148780e5a15b7f4ea77948_720w.jpg?source=172ae18b"><meta data-rh=true property=og:type content=article><meta data-rh=true property=og:site_name content=知乎专栏><link crossorigin rel=search type=application/opensearchdescription+xml href=https://static.zhihu.com/heifetz/search.xml title=知乎><style>:root{--sf-img-5: url("")}.Button{background:none;border:1px solid;border-radius:3px;cursor:pointer;display:inline-block;font-size:14px;line-height:32px;padding:0 16px;text-align:center}.Button{color:#8590a6}.Button::-moz-focus-inner{border:0;padding:0}.Button:focus{outline:none;-webkit-transition:-webkit-box-shadow .3s;transition:-webkit-box-shadow .3s;transition:box-shadow .3s;transition:box-shadow .3s,-webkit-box-shadow .3s}.Button:disabled{cursor:default;opacity:.5;pointer-events:none}.Button--blue{border-color:#056de8;color:#056de8}.Button--blue:hover{background-color:rgba(5,109,232,.06)}.Button--primary.Button--blue{background-color:#056de8;color:#fff}.Button--primary.Button--blue:hover{background-color:#0461cf;border-color:#0461cf}.Button--plain{background-color:transparent;border:none;border-radius:0;height:auto;line-height:inherit;padding:0}.Button--link:hover,.Button--plain:hover{background-color:transparent}.Button--plain:hover,html[data-theme=dark] .Button--plain:hover{color:#76839b}.Button--withIcon.Button--plain{padding:0}.Button--withIcon.Button--withLabel .Button-zi{margin-right:4px}@-webkit-keyframes spring-in{0%{opacity:.01;-webkit-transform:translate(-50%,-20px);transform:translate(-50%,-20px)}to{opacity:1;-webkit-transform:translate(-50%);transform:translate(-50%)}}@keyframes spring-in{0%{opacity:.01;-webkit-transform:translate(-50%,-20px);transform:translate(-50%,-20px)}to{opacity:1;-webkit-transform:translate(-50%);transform:translate(-50%)}}@-webkit-keyframes spring-out{0%{opacity:1;-webkit-transform:translate(-50%);transform:translate(-50%)}to{opacity:0;-webkit-transform:translate(-50%,-20px);transform:translate(-50%,-20px)}}@keyframes spring-out{0%{opacity:1;-webkit-transform:translate(-50%);transform:translate(-50%)}to{opacity:0;-webkit-transform:translate(-50%,-20px);transform:translate(-50%,-20px)}}.InputLike{border-radius:3px;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transition:background .2s,border .2s;transition:background .2s,border .2s}.Popover{display:inline-block;position:relative}.Input-wrapper{-webkit-box-align:center;-ms-flex-align:center;align-items:center;background:#fff;border:1px solid #ebebeb;border-radius:3px;-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:14px;height:34px;padding:4px 10px;position:relative;-webkit-transition:background .2s,border .2s;transition:background .2s,border .2s;width:180px}.Input{-webkit-box-flex:1;background:transparent;border:none;-ms-flex:1 1;flex:1 1;font-family:inherit;font-size:inherit;font-weight:inherit;overflow:hidden;padding:0;resize:none}.Input:disabled{color:#bfbfbf}.Input:focus{outline:none}input.Input{color:#121212;height:24px;line-height:24px}.Input:not(input){line-height:24px}.Input::-moz-placeholder{color:#8590a6}.Input::-webkit-input-placeholder{color:#8590a6}.Input::placeholder{color:#8590a6}.Avatar{background:#fff}.ztext{line-height:1.6;word-break:break-word}.ztext>:first-child{margin-top:0}.ztext>:last-child{margin-bottom:0}.ztext h2{font-synthesis:style}.ztext a:focus{outline:none;-webkit-transition:-webkit-box-shadow .3s;transition:-webkit-box-shadow .3s;transition:box-shadow .3s;transition:box-shadow .3s,-webkit-box-shadow .3s}.ztext p.ztext-empty-paragraph{margin:-.8em 0}.ztext .origin_image.zh-lightbox-thumb{cursor:-webkit-zoom-in}.ztext pre{-webkit-overflow-scrolling:touch}@-webkit-keyframes Bounce{0%,to{-webkit-transform:translateY(-100%);transform:translateY(-100%)}50%{-webkit-transform:translateY(100%);transform:translateY(100%)}}@keyframes Bounce{0%,to{-webkit-transform:translateY(-100%);transform:translateY(-100%)}50%{-webkit-transform:translateY(100%);transform:translateY(100%)}}@-webkit-keyframes linear-double{0%{-webkit-transform:translateX(-56%);transform:translateX(-56%)}to{-webkit-transform:translateX(56%);transform:translateX(56%)}}@keyframes linear-double{0%{-webkit-transform:translateX(-56%);transform:translateX(-56%)}to{-webkit-transform:translateX(56%);transform:translateX(56%)}}@supports not ((-webkit-backdrop-filter:blur(16px)) or (backdrop-filter:blur(16px))){.VideoCardPlayButton-withFileSize--outer .VideoCardPlayButton-withFileSize{background-color:hsla(0,0%,7%,.8)}}@-webkit-keyframes CircleLoadingBarRotator{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(270deg);transform:rotate(270deg)}}@keyframes CircleLoadingBarRotator{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(270deg);transform:rotate(270deg)}}@-webkit-keyframes CircleLoadingBarDash{0%{stroke-dashoffset:187}50%{stroke-dashoffset:46.75;-webkit-transform:rotate(135deg);transform:rotate(135deg)}to{stroke-dashoffset:187;-webkit-transform:rotate(450deg);transform:rotate(450deg)}}@keyframes CircleLoadingBarDash{0%{stroke-dashoffset:187}50%{stroke-dashoffset:46.75;-webkit-transform:rotate(135deg);transform:rotate(135deg)}to{stroke-dashoffset:187;-webkit-transform:rotate(450deg);transform:rotate(450deg)}}body{font-family:-apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif}button{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;color:inherit;cursor:pointer;font:inherit;outline:none;padding:0}body,button{margin:0}h1,h2,h3{font:inherit;margin:0}ul{margin:0;padding:0}a{color:inherit;text-decoration:none}.CornerAnimayedFlex{-webkit-transition:height .2s ease;transition:height .2s ease;width:40px}.CornerAnimayedFlex--hidden{height:0}.CornerButtons{-webkit-box-orient:vertical;-webkit-box-direction:normal;bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;position:fixed;right:12px}.AppHeader-profileAvatar{vertical-align:top}.AppHeaderProfileMenu-creatorHintPopover{position:absolute;right:0;top:0;z-index:-1}.AppHeaderProfileMenu-creatorHintToggler{height:30px;width:30px}.AppHeader-menu{margin-left:6px}body{color:#121212}body{-webkit-tap-highlight-color:rgba(18,18,18,0)}.WhiteBg-body{background:#fff}.App-main{padding-bottom:46px}@media (max-width:690px){body{background:#fff}.App-main{padding:0}}.ColumnPageHeader-Wrapper{width:100%}.ColumnPageHeader{background:#fff;height:52px;position:relative;width:100%;z-index:1}.ColumnPageHeader{background-clip:content-box;-webkit-box-shadow:0 1px 3px hsla(0,0%,7%,.1)}.ColumnPageHeader-profile{left:50%;position:absolute;top:50%;-webkit-transform:translate(522px,-50%);transform:translate(522px,-50%)}.ColumnPageHeader-content{margin:0 auto;padding:0 16px;position:relative;width:1000px}.ColumnPageHeader-Title,.ColumnPageHeader-content{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;height:52px}.ColumnPageHeader-Title{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin-left:16px}.ColumnPageHeader-Line{background-color:#ebebeb;height:29px;width:1px}.ColumnPageHeader-Line{margin-left:17px}.ColumnPageHeader-TitleName{-webkit-box-orient:vertical;-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-flow:column;flex-flow:column}.ColumnPageHeader-TitleMeta{color:#8590a6}.ColumnPageHeader-TitleMeta{font-size:12px}.ColumnPageHeader-TitleColumn{font-synthesis:style;font-weight:600}.ColumnPageHeader-TitleColumn{font-size:14px}.ColumnPageHeader-Button{-webkit-box-flex:1;-webkit-box-pack:end;-ms-flex-pack:end;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex:1 1;flex:1 1;justify-content:flex-end}.ColumnPageHeader-WriteButton{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex}.ColumnPageHeader-WriteButton .Zi--EditSurround{margin-left:-3px;margin-right:4px}.ColumnPageHeader-MenuToggler{height:32px;padding:0 20px}.FollowButton{min-width:96px}.FollowButton-icon{fill:currentColor;margin-right:8px}.AuthorInfo{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:justify;-ms-flex-pack:justify;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:space-between;max-width:654px;position:relative}.AuthorInfo-avatar{vertical-align:top}.AuthorInfo-content{-webkit-box-flex:1;-ms-flex:1 1;flex:1 1;margin-left:14px;overflow:hidden}.AuthorInfo-head{-webkit-box-align:center;-ms-flex-align:center;-ms-flex-negative:0;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;flex-shrink:0;font-size:15px;line-height:1.1}.AuthorInfo-name{font-synthesis:style;font-weight:600}.AuthorInfo-badge{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:14px;margin-top:2px}.AuthorInfo-badgeText{color:#646464;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.AuthorInfo-detail{overflow:hidden}.LabelContainer-wrapper{margin:16px 0}.LabelContainer-wrapper:empty{margin:0}.Reward-rewardBtn{color:#fff}.Reward-rewardBtn{background:#f36}.Reward-rewardBtn{border-radius:4px;height:34px;margin-top:27px;width:80px}.Reward{color:grey;text-align:center}.Reward{font-size:14px}.Reward-tagline{font-size:15px;line-height:18px;margin-top:60px}.Reward-countZero{margin-top:20px}.ContentItem-title{line-height:1.6}.ContentItem-title{margin-bottom:-4px;margin-top:-4px}.ContentItem-title a:hover{color:#175199}.ContentItem-actions{-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:#646464;display:-webkit-box;display:-ms-flexbox;display:flex;margin:0-20px -10px;padding:10px 20px}.ContentItem-actions{background:#fff}.ContentItem-actions{clear:both}.ContentItem-actions>*{-ms-flex-negative:0;flex-shrink:0}.ContentItem-action{font-size:14px;margin-left:24px}.ContentItem-action:first-child{margin-left:0}.ContentItem-time{color:#8590a6;font-size:14px;margin-top:10px}.ContentItem-main{display:-webkit-box;display:-ms-flexbox;display:flex}.ContentItem-image{float:left;margin-right:16px}.ContentItem-head{-webkit-box-flex:1;-ms-flex:1 1;flex:1 1;margin-right:6px;overflow:hidden}.TopicList{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}.TopicList .Topic:not(:last-child){margin-right:5px}.TopicList .Topic+.Topic{vertical-align:middle}.VoteButton{color:#056de8;padding:0 10px}.VoteButton{background:rgba(5,109,232,.1)}.VoteButton{border-color:transparent}.VoteButton:not(:disabled):hover{background-color:rgba(5,109,232,.15)}.VoteButton:disabled:hover{background:#f6f6f6}.VoteButton-TriangleUp{margin-right:5px}.VoteButton--down{margin-left:4px}.Post-ActionMenuButton{margin-left:24px}.RichContent-actions{background:#fff}.RichContent-actions{bottom:0;left:0;width:100vw}@media (min-width:690px){.RichContent-actions{margin-bottom:10px}}.RichContent-actions .ContentItem-actions{position:relative}.RichContent-actions .ContentItem-actions>:nth-child(n){margin-left:24px}.RichContent-actions .ContentItem-actions>:first-child{margin:0}@media (max-width:690px){.RichContent-actions{-webkit-box-shadow:none;box-shadow:none;font-synthesis:style;font-weight:600}}@-webkit-keyframes Post-SideActions-spread{0%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}to{opacity:0;-webkit-transform:scale(1.8);transform:scale(1.8)}}@keyframes Post-SideActions-spread{0%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}to{opacity:0;-webkit-transform:scale(1.8);transform:scale(1.8)}}.Post-Author{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex}.Post-Author .AuthorInfo{-webkit-box-flex:1;-ms-flex:1 1;flex:1 1;overflow:hidden;white-space:nowrap}.Post-Author .AuthorInfo-name{color:#444}.Post-Author .AuthorInfo-detail{color:#646464}@-webkit-keyframes slideInUp{0%{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);visibility:visible}to{-webkit-transform:translateZ(0);transform:translateZ(0)}}@keyframes slideInUp{0%{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);visibility:visible}to{-webkit-transform:translateZ(0);transform:translateZ(0)}}@-webkit-keyframes fsFadeIn{0%{opacity:0}to{opacity:1}}@keyframes fsFadeIn{0%{opacity:0}to{opacity:1}}@-webkit-keyframes fsFadeOut{0%{opacity:1}to{opacity:0}}@keyframes fsFadeOut{0%{opacity:1}to{opacity:0}}@-webkit-keyframes fsSlideUp{0%{opacity:0;-webkit-transform:translateY(40px);transform:translateY(40px)}to{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes fsSlideUp{0%{opacity:0;-webkit-transform:translateY(40px);transform:translateY(40px)}to{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes fsSlideDown{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}to{opacity:0;-webkit-transform:translateY(40px);transform:translateY(40px)}}@keyframes fsSlideDown{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}to{opacity:0;-webkit-transform:translateY(40px);transform:translateY(40px)}}.Post-RichTextContainer{position:relative}.Post-NormalMain>.Post-RichTextContainer{overflow:visible}.BlockTitle{font-synthesis:style;font-weight:600;margin-top:40px;padding-bottom:12px}.BlockTitle{color:#121212;font-size:16px;line-height:1.375}.BlockTitle{border-color:#ebebeb}.BlockTitle{border-bottom-style:solid;border-width:1px}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){.BlockTitle{border-width:.5px}}@media (-webkit-min-device-pixel-ratio:3),(min-resolution:288dpi){.BlockTitle{border-width:.33333px}}@media (-webkit-min-device-pixel-ratio:4),(min-resolution:384dpi){.BlockTitle{border-width:.25px}}.Column-ColumnItem{margin:24px 0}.Column-ColumnItem .ContentItem-main{height:40px}.Column-ColumnItem .ContentItem-head{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-pack:center;-ms-flex-pack:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;justify-content:center}.Column-ColumnItem .ContentItem-title{font-synthesis:style;font-weight:600}.Column-ColumnItem .ContentItem-title{color:#444;font-size:15px}.Column-ColumnItem .ContentItem-title{margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Column-ColumnItem .ContentItem-meta{color:#646464;font-size:14px;line-height:1.5;margin-top:0}.Column-ColumnItem .ContentItem-meta{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Post-content{background:#fff}.Post-content{min-width:1000px}.ContentItem-time{padding:16px 0}@media (max-width:690px){.ContentItem-time{margin-top:10px}}.Post-NormalMain>div,.Post-NormalSub>div{margin:0 auto;overflow:hidden;width:690px}.Post-NormalMain .Post-Header{margin:0 auto;width:690px}.Post-NormalSub .Comments-container{border-top:52px solid transparent;margin:-52px auto 0}.PostIndex-Contributions{margin-bottom:-8px!important;padding-top:30px}.PostIndex-Contributions .BlockTitle{margin-top:0}.Post-Main,.Post-Sub{-webkit-box-sizing:border-box;box-sizing:border-box}.Post-Main:focus{outline:none}.Post-Main .Post-topicsAndReviewer{display:-webkit-box;display:-ms-flexbox;display:flex}.Post-Main .Post-Title{font-synthesis:style;font-weight:600}.Post-Main .Post-Title{word-wrap:break-word;font-size:24px;line-height:1.22;margin:24px 0}@media (max-width:690px){.Post-Main .Post-Title{margin:16px 0}}.Post-Main .Voters{color:#8590a6;display:block;font-size:14px;margin-top:16px}.Post-Main .Post-Topics{margin-bottom:-10px;padding:16px 0}.Post-Main .Post-Topics .Topic{font-size:13px;height:33px;line-height:33px;margin-bottom:10px;overflow:hidden}.PostItem{border-radius:5px;-webkit-box-shadow:0 6px 14px 0 hsla(0,0%,7%,.06);box-shadow:0 6px 14px 0 hsla(0,0%,7%,.06);height:226px;min-width:245px;width:245px}.PostItem{background:#fff}.PostItem{margin-right:14px;overflow:hidden;position:relative;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s}.PostItem:hover{-webkit-transform:scale(1.04);transform:scale(1.04)}.PostItem-TitleImage{border-top-left-radius:5px;border-top-right-radius:5px;height:123px;-o-object-fit:cover;object-fit:cover;width:245px}.PostItem-Title{font-synthesis:style;font-weight:600}.PostItem-Title{color:#121212;font-size:16px;min-width:225px}.PostItem-Title{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;line-height:22px;margin:12px;overflow:hidden;text-overflow:ellipsis}.PostItem-Summary{color:#121212;font-size:14px}.PostItem-Summary{-webkit-line-clamp:6;-webkit-box-orient:vertical;display:-webkit-box;line-height:20px;margin:8px 12px;max-height:118px;overflow:hidden;text-overflow:ellipsis}.PostItem-Footer{-webkit-box-pack:justify;-ms-flex-pack:justify;bottom:12px;color:#8590a6;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:14px;justify-content:space-between;left:12px;position:absolute;width:100%}.PostItem-Footer{line-height:20px}.PostItem-FooterTitle{margin-right:24px}.PagingButton{background:#fff;border-radius:100px;height:48px;width:48px}.PagingButton{-webkit-box-shadow:0 6px 13px 0 hsla(0,0%,7%,.06);box-shadow:0 6px 13px 0 hsla(0,0%,7%,.06)}.PagingButton{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:center;margin-top:90px}.PagingButton:hover{-webkit-transform:scale(1.04);transform:scale(1.04);z-index:9}.PagingButton:disabled{visibility:hidden}.PagingButton-Next{margin-left:40px}.PagingButton-Previous{margin-right:40px}.Recommendations-Main{background:#f6f6f6}.Recommendations-Main{margin:24px auto!important;position:relative}.Recommendations-List{-webkit-box-pack:center;-ms-flex-pack:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:center;margin:32px auto}@media (min-width:690px){.Recommendations-BlockTitle{margin:24px auto 4px;width:690px}}@-webkit-keyframes WriteIndexLoading{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes WriteIndexLoading{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.css-1l12z7y{box-shadow:0px 16px 32px rgba(0,0,0,0.04)}.css-1hlrcxk{-webkit-transition-property:fill;transition-property:fill;-webkit-transition-duration:0.25s;transition-duration:0.25s;-webkit-transition-timing-function:ease-in;transition-timing-function:ease-in}.css-1tzrnvf{box-sizing:border-box;margin:0;min-width:0;max-width:100%;background-color:#FFFFFF;width:30px;height:30px;border-radius:2px}.css-78p1r9{box-sizing:border-box;margin:0;min-width:0;margin-left:auto;margin-right:auto;max-width:690px;margin-top:0}@media screen and (min-width:40em){.css-78p1r9{margin-top:1em}}.css-1oljx3p{box-sizing:border-box;margin:0;min-width:0;position:relative;padding-bottom:41.66666666666667%;height:0;border-radius:inherit}.css-1ld0bim{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:inherit}.css-1y9jkzv{box-sizing:border-box;margin:0;min-width:0;max-width:100%;background-color:#FFFFFF;width:38px;height:38px;border-radius:50%}.css-1yuhvjn{margin-top:16px}.css-79elbk{position:relative}.css-4em6pe{word-break:break-word;line-height:1.6}.css-4em6pe>[data-first-child]{margin-top:0}.css-4em6pe>:last-child{margin-bottom:0}.css-4em6pe h2{clear:left;margin-top:calc((1.4em*2)/1.2);margin-bottom:calc(1.4em/1.2);font-size:1.2em;line-height:1.5;font-weight:600}.css-4em6pe a:focus{outline:none;-webkit-transition:box-shadow 0.3s;transition:box-shadow 0.3s}.css-4em6pe p{margin:1.4em 0}.css-4em6pe figure{margin:1.4em 0}.css-4em6pe figure .origin_image{margin:0 auto}.css-4em6pe .origin_image{display:block;max-width:100%;height:auto}.css-4em6pe .origin_image.zh-lightbox-thumb{cursor:-webkit-zoom-in;cursor:-moz-zoom-in;cursor:zoom-in}.css-4em6pe code{font-family:Menlo,Monaco,Consolas,"Andale Mono","lucida console","Courier New",monospace}.css-4em6pe pre{padding:calc(0.8em/0.9);font-size:0.9em;word-break:initial;word-wrap:initial;white-space:pre;overflow:auto;-webkit-overflow-scrolling:touch;background:#F6F6F6;border-radius:4px}.css-4em6pe pre code{margin:0;padding:0;font-size:inherit;border-radius:0;background-color:inherit}.css-4em6pe .lazy[data-lazy-status="ok"]{-webkit-animation:animation-1yvu044 0.5s ease-in}.css-4em6pe .highlight{margin:1em 0}.css-4em6pe .highlight pre{margin:0}.css-4em6pe .highlight .k{font-weight:600}.css-4em6pe .highlight .o{font-weight:600}.css-4em6pe .highlight .c1{font-style:italic;color:#999999}.css-4em6pe .highlight .kn{font-weight:600}.css-4em6pe .highlight .nb{color:#056DE8}.css-4em6pe .highlight .nc{font-weight:600;color:#175199}.css-4em6pe .highlight .nf{font-weight:600;color:#F1403C}.css-4em6pe .highlight .nn{color:#646464}.css-4em6pe .highlight .ow{font-weight:600}.css-4em6pe .highlight .mi{color:#056DE8}.css-4em6pe .highlight .se{color:#F1403C}.css-4em6pe .highlight .si{color:#F1403C}.css-4em6pe .highlight .s1{color:#F1403C}.css-4em6pe .highlight .bp{color:#999999}.css-4em6pe .highlight::-webkit-scrollbar{width:6px;height:6px}.css-4em6pe .LinkCard.new{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;box-sizing:border-box;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:390px;min-height:84px;border-radius:8px;max-width:100%;overflow:hidden;margin:16px auto;padding:12px 12px 9px 12px;background-color:#F6F6F6}.css-4em6pe .LinkCard.new,.css-4em6pe .LinkCard.new:hover{-webkit-text-decoration:none;text-decoration:none;border:none!important;color:inherit!important}.css-4em6pe .LinkCard.new .LinkCard-contents{display:block;-webkit-flex:1 1 auto;-ms-flex:1 1 auto;flex:1 1 auto;position:relative}.css-4em6pe .LinkCard.new .LinkCard-title{display:-webkit-box;font-size:15px;font-weight:500;margin-bottom:2px;color:#121212;-webkit-box-orient:vertical;-webkit-line-clamp:1}.css-4em6pe .LinkCard.new .LinkCard-title.two-line{line-height:20px;display:-webkit-box;text-overflow:ellipsis;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2}.css-4em6pe .LinkCard.new .LinkCard-desc{display:-webkit-box;font-size:13px;height:18px;line-height:18px;color:#999999;word-break:break-all;text-overflow:ellipsis;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.css-4em6pe .LinkCard.new .LinkCard-desc svg{margin-right:2px}.css-4em6pe .LinkCard.new .LinkCard-image{-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;background-color:#EBEBEB;background-size:cover;background-position:center;position:relative;display:block;width:60px;margin-left:20px;object-fit:cover;border-radius:inherit;overflow:hidden}.css-4em6pe .LinkCard.new .LinkCard-image img{width:100%;height:100%;object-fit:cover}@-webkit-keyframes animation-1yvu044{from{opacity:0}to{opacity:1}}@keyframes animation-1yvu044{from{opacity:0}to{opacity:1}}.css-1s3a4zw{position:relative;display:inline-block;padding:0 12px;color:#056DE8;vertical-align:top;border-radius:100px;background:rgba(5,109,232,0.1)}.css-1s3a4zw:hover{background-color:rgba(5,109,232,0.15)}.css-1gomreu{position:relative;display:inline-block}.css-1any501{box-sizing:border-box;margin:0;min-width:0;max-width:100%;background-color:#FFFFFF;width:40px;height:40px;border-radius:50%}@keyframes container-rotate{to{transform:rotate(360deg)}}@keyframes fill-unfill-rotate{12.5%{transform:rotate(135deg)}25%{transform:rotate(270deg)}37.5%{transform:rotate(405deg)}50%{transform:rotate(540deg)}62.5%{transform:rotate(675deg)}75%{transform:rotate(810deg)}87.5%{transform:rotate(945deg)}to{transform:rotate(1080deg)}}@keyframes mask-1-spin{0%{transform:rotate(157deg)}50%{transform:rotate(30deg)}to{transform:rotate(157deg)}}@keyframes mask-2-spin{0%{transform:rotate(-155deg)}50%{transform:rotate(-30deg)}to{transform:rotate(-155deg)}}@-webkit-keyframes spinnerBladeFade{0%{opacity:.85}50%{opacity:.25}to{opacity:.25}}@keyframes spinnerBladeFade{0%{opacity:.85}50%{opacity:.25}to{opacity:.25}}img:not([src]),img[src=""]{opacity:0}@-webkit-keyframes skeleton-wave{0%{-webkit-transform:translateX(-8000%);transform:translateX(-8000%)}to{-webkit-transform:translateX(10000%);transform:translateX(10000%)}}@keyframes skeleton-wave{0%{-webkit-transform:translateX(-8000%);transform:translateX(-8000%)}to{-webkit-transform:translateX(10000%);transform:translateX(10000%)}}@-webkit-keyframes linear-double{0%{-webkit-transform:translateX(-56%);transform:translateX(-56%)}to{-webkit-transform:translateX(56%);transform:translateX(56%)}}@keyframes linear-double{0%{-webkit-transform:translateX(-56%);transform:translateX(-56%)}to{-webkit-transform:translateX(56%);transform:translateX(56%)}}@-webkit-keyframes rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.css-gdd4kf{padding:0px;font-size:14px;line-height:inherit;text-align:center;cursor:pointer;border:medium none;display:flex;-moz-box-align:center;align-items:center;-moz-box-pack:center;justify-content:center;background:rgb(255,255,255);border-radius:4px;width:40px;height:40px;color:rgb(133,144,166);box-shadow:rgba(18,18,18,0.1) 0px 1px 3px}.css-gdd4kf:focus{outline:none;transition:box-shadow 0.3s ease 0s}.css-gdd4kf:focus-visible{box-shadow:rgb(255,255,255) 0px 0px 0px 2px,rgba(5,109,232,0.3) 0px 0px 0px 4px}.css-gdd4kf:disabled{cursor:default;opacity:0.5}.css-gdd4kf:hover{background:rgb(211,211,211)}.css-8pdeid{position:absolute;top:0px;height:1200px}@keyframes animation-p6x5s9{0%{transform:translateX(-100%)}40%{transform:translateX(0px)}60%{transform:translateX(0px)}100%{transform:translateX(100%)}}@keyframes animation-p6x5s9{0%{transform:translateX(-100%)}40%{transform:translateX(0px)}60%{transform:translateX(0px)}100%{transform:translateX(100%)}}.css-plbgu{box-sizing:border-box;min-width:0px}.css-1fo89v5{box-sizing:border-box;margin:0px 0px 10px;min-width:0px;flex:1 1 auto;display:flex}.css-x0pxoz{box-sizing:border-box;margin:0px;min-width:0px;border-radius:4px;border:1px solid rgb(235,235,235);flex:1 1 auto;padding:8px 12px}.css-z07uxh{box-sizing:border-box;margin:0px;min-width:0px;position:relative;border:1px solid rgb(235,235,235);border-radius:4px;flex-direction:column;-moz-box-align:stretch;align-items:stretch;display:flex}.css-we6n55{box-sizing:border-box;margin:0px;min-width:0px;position:relative;flex:0 0 auto;padding-left:20px;padding-right:20px;height:50px;-moz-box-align:center;align-items:center;-moz-box-pack:justify;justify-content:space-between;display:flex}.css-we6n55::before{display:block;content:" ";position:absolute;inset:-50%;pointer-events:none;transform:scale(0.5);border-bottom:1px solid rgb(235,235,235)}.css-vpssrj{box-sizing:border-box;margin:0px;min-width:0px;font-size:15px;color:rgb(68,68,68);font-weight:600}.css-1k10w8f{box-sizing:border-box;margin:0px;min-width:0px;cursor:default}.css-59erns{box-sizing:border-box;margin:0px;min-width:0px;flex:1 1 auto;display:flex}.css-840pn3{flex:1 1 auto;position:relative}.css-1frn93x{box-sizing:border-box;margin:0px;min-width:0px;padding-top:10px;padding-bottom:10px;min-height:100%}@keyframes animation-1alkx44{0%,100%{transform:translateY(-100%)}50%{transform:translateY(100%)}}@keyframes animation-1alkx44{0%,100%{transform:translateY(-100%)}50%{transform:translateY(100%)}}.css-1phd9a0{object-fit:cover}.css-i6bazn{overflow:hidden}.css-ip4bff{border:medium none!important;background:none!important;font-size:15px}.css-ip4bff .Editable-unstyled{margin:0px!important}.css-ip4bff .RichText{padding:0px}.css-ip4bff .Dropzone{min-height:auto!important}.css-194v73m{box-sizing:border-box;margin:0px;min-width:0px;display:flex;padding:10px 20px 14px}.css-1jll2aj{box-sizing:border-box;margin:0px;min-width:0px;flex:0 0 auto}.css-14nvvry{box-sizing:border-box;margin:0px 0px 0px 10px;min-width:0px;flex:1 1 auto}.css-1besdh8{box-sizing:border-box;margin:0px;min-width:0px;-moz-box-pack:justify;justify-content:space-between;color:rgb(153,153,153);display:flex}.css-swj9d4{box-sizing:border-box;margin:0px;min-width:0px;-moz-box-align:center;align-items:center;flex:0 1 auto;display:flex}.css-1tww9qq{box-sizing:border-box;margin:0px;min-width:0px;-moz-box-align:center;align-items:center;height:16px;display:flex}.css-1qe0v6x{box-sizing:border-box;margin:0px;min-width:0px;-moz-box-align:center;align-items:center;justify-content:stretch;flex-wrap:wrap;flex:1 999999 auto;display:flex;max-height:30px;overflow:hidden}.css-1ssbn0c{height:30px}.css-zgte1c{margin:2px;cursor:pointer;flex-shrink:0}.css-1ygdre8{box-sizing:border-box;margin:4px 0px 0px;min-width:0px;color:rgb(68,68,68);overflow-wrap:break-word;font-size:15px;line-height:21px}.css-1ygdre8 p{margin:0px}.css-dbby2p{box-sizing:border-box;margin:4px 0px 0px;min-width:0px;-moz-box-align:center;align-items:center;-moz-box-pack:justify;justify-content:space-between;display:flex}.css-82fsyv{box-sizing:border-box;margin:0px;min-width:0px;-moz-box-align:center;align-items:center;flex:0 0 auto;font-size:14px;color:rgb(153,153,153);display:flex}.css-12cl38p{box-sizing:border-box;margin:0px 4px 0px 0px;min-width:0px}.css-18opwoy{box-sizing:border-box;margin:0px;min-width:0px;-moz-box-align:center;align-items:center;flex:0 0 auto;display:flex}.css-18opwoy .Button{margin-left:16px}.css-1o56bgb{display:inline-block;padding:0px;font-size:14px;line-height:inherit;color:rgb(133,144,166);text-align:center;cursor:pointer;background:transparent;border:medium none;border-radius:0px;height:auto}.css-1o56bgb:focus{outline:none;transition:box-shadow 0.3s ease 0s}.css-1o56bgb:focus-visible{box-shadow:rgb(255,255,255) 0px 0px 0px 2px,rgba(5,109,232,0.3) 0px 0px 0px 4px}.css-1o56bgb:disabled{cursor:default;opacity:0.5}.css-15ro776{margin-right:4px}.css-h1yvwn{display:inline-block;padding:0px;font-size:14px;line-height:inherit;color:rgb(133,144,166);text-align:center;cursor:pointer;background:transparent;border:medium none rgb(133,144,166);border-radius:0px;height:auto}.css-h1yvwn:focus{outline:none;transition:box-shadow 0.3s ease 0s}.css-h1yvwn:focus-visible{box-shadow:rgb(255,255,255) 0px 0px 0px 2px,rgba(5,109,232,0.3) 0px 0px 0px 4px}.css-h1yvwn:disabled{cursor:default;opacity:0.5}.css-h1yvwn:hover{background-color:transparent;color:rgb(124,136,160)}.css-h7rrn2{box-sizing:border-box;margin:12px 0px 0px;min-width:0px;background-color:rgb(246,246,246);position:relative;border-radius:8px;width:120px;height:120px}.css-8z95sv{width:100%;height:100%;border-radius:8px;object-fit:cover;object-position:unset}.comment_sticker .css-8z95sv{cursor:default}.css-1hnxfhy{box-sizing:border-box;margin:0px;min-width:0px;border:2px solid rgb(246,246,246);border-radius:3px;font-size:12px;line-height:24px;font-weight:600;background-color:rgb(246,246,246);display:flex}.css-gjiv4z{box-sizing:border-box;margin:0px;min-width:0px;color:rgb(18,18,18);border-radius:2px;text-align:center;cursor:pointer;width:50px;height:24px;background-color:rgb(255,255,255)}.css-1v9si9f{box-sizing:border-box;margin:0px;min-width:0px;color:rgb(128,128,128);border-radius:2px;text-align:center;cursor:pointer;width:50px;height:24px;background-color:transparent}.css-y06ck6{box-sizing:border-box;margin:0px;min-width:0px;color:rgb(23,81,153);position:relative;display:block}.css-1s1htbw{box-sizing:border-box;margin:0px;min-width:0px;max-width:100%;width:24px;height:24px;border-radius:2px;filter:brightness(0.95);display:block;position:relative;background-color:rgb(246,246,246);flex:0 0 auto;text-indent:-9999px;overflow:hidden}.css-1rd0h6f{box-sizing:border-box;margin:0px;min-width:0px;font-size:15px;font-weight:bold;text-decoration:none;color:rgb(68,68,68);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.css-1oi6kgx{box-sizing:border-box;margin:0px 10px 0px 0px;min-width:0px;max-width:100%;background-color:rgb(255,255,255);width:40px;height:40px;border-radius:3px;flex:0 0 auto}.Stars{-webkit-box-pack:start;-ms-flex-pack:start;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:flex-start}.Stars>svg{margin:0!important}.Stars>span{font-weight:500;margin-left:4px}.FeeConsultCard{-webkit-box-pack:start;-ms-flex-pack:start;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;background-color:#f6f6f6;border-radius:12px;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:flex-start;margin:0 auto;max-width:390px;min-height:84px;overflow:hidden;padding:12px;position:relative}.FeeConsultCard>img{border-radius:50%;height:60px;margin-right:12px;width:60px}.FeeConsultCard>div:first-of-type{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;justify-content:center;width:calc(100% - 72px)}.FeeConsultCard>div:first-of-type>div{-webkit-box-pack:start;-ms-flex-pack:start;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:12px;justify-content:flex-start;line-height:16px;margin-bottom:6px}.FeeConsultCard>div:first-of-type>div>svg{height:14px;margin-right:4px;width:14px}.FeeConsultCard>div:first-of-type>div:first-child{-webkit-box-pack:start;-ms-flex-pack:start;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;color:#121212;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:15px;font-weight:500;justify-content:flex-start}.FeeConsultCard>div:first-of-type>div:last-of-type{margin-bottom:0}.FeeConsultCard-name{line-height:20px!important}.FeeConsultCard-times{color:#999}.FeeConsultCard-times>svg{fill:#999}.FeeConsultCard-times>span{margin-right:6px}.FeeConsultCard-like{color:grey}.FeeConsultCard-like>svg{fill:grey}.FeeConsultCard-fee{color:#0084ff;font-size:13px;font-weight:500;line-height:16px;position:absolute;right:12px}.FeeConsultCard-fee>svg{bottom:-7px;position:relative}.LinkCard-title{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;max-height:40px}.LinkCard-image{-o-object-fit:cover}@-webkit-keyframes LoadingBarForward{0%{-webkit-transform:translateX(-100%);transform:translateX(-100%)}40%{-webkit-transform:translateX(0);transform:translateX(0)}60%{-webkit-transform:translateX(0);transform:translateX(0)}to{-webkit-transform:translateX(100%);transform:translateX(100%)}}@keyframes LoadingBarForward{0%{-webkit-transform:translateX(-100%);transform:translateX(-100%)}40%{-webkit-transform:translateX(0);transform:translateX(0)}60%{-webkit-transform:translateX(0);transform:translateX(0)}to{-webkit-transform:translateX(100%);transform:translateX(100%)}}.LinkCard.new{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-box-align:center;-ms-flex-align:center;-webkit-box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;-ms-flex-direction:row}.LinkCard.new,.LinkCard.new:hover{border:none!important;color:inherit!important;text-decoration:none}.LinkCard.new .LinkCard-contents{-webkit-box-flex:1;-ms-flex:1 1 auto}.LinkCard.new .LinkCard-title{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:block;display:-webkit-box}.LinkCard.new .LinkCard-title.two-line{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}.LinkCard.new .LinkCard-desc{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:block;display:-webkit-box}.LinkCard.new .LinkCard-image{-webkit-box-flex:0;-ms-flex:0 0 auto;-o-object-fit:cover}.LinkCard.new .LinkCard-image img{-o-object-fit:cover}@-webkit-keyframes fxRichTextFadeIn{0%{opacity:0}to{opacity:1}}@keyframes fxRichTextFadeIn{0%{opacity:0}to{opacity:1}}.RichText--clearBoth:after,.RichText--clearBoth:before{clear:both;content:"";display:block}.RichText .lazy[data-lazy-status=ok]{-webkit-animation:fxRichTextFadeIn .5s ease-in;animation:fxRichTextFadeIn .5s ease-in;background-color:transparent}.Dropzone{position:relative}.Editable-languageSuggestions{position:fixed;z-index:1}.Editable-languageSuggestionsInput{cursor:pointer}.Editable-languageSuggestionsInput input{cursor:inherit}.Editable-languageSuggestionsInput input:focus{cursor:text}.Editable{padding:0;position:relative}.Editable-content{cursor:text}.Editable .public-DraftEditorPlaceholder-root{color:#8590a6;pointer-events:none;position:absolute}.Editable-styled:first-child,.Editable-unstyled:first-child{margin-top:0}.Editable-styled:last-child,.Editable-unstyled:last-child{margin-bottom:0}</style><meta itemprop=name content="la vie" class=sf-hidden><meta itemprop=image content="https://picx.zhimg.com/v2-09f987a1d8c81829254ea0af23947347_l.jpg?source=172ae18b" class=sf-hidden><meta itemprop=url content=https://www.zhihu.com/people/la-vie-est-belle class=sf-hidden><meta itemprop=zhihu:followerCount class=sf-hidden><link crossorigin rel="shortcut icon" type=image/x-icon href=""><style>.sf-hidden{display:none!important}</style><link rel=canonical href=https://zhuanlan.zhihu.com/p/75629282><meta http-equiv=content-security-policy content="default-src 'none'; font-src 'self' data:; img-src 'self' data:; style-src 'unsafe-inline'; media-src 'self' data:; script-src 'unsafe-inline' data:; object-src 'self' data:;"><style>img[src="data:,"],source[src="data:,"]{display:none!important}</style><body class="WhiteBg-body PostIndex-body" data-rh=class><img src=data:, alt class=sf-hidden hidden><div id=root><div class=App><div class="LoadingBar css-uzm3ri sf-hidden"></div><div><span style=position:absolute;top:-10000px;left:-10000px role=log aria-live=assertive></span></div><main role=main class=App-main><div class=Post-content data-zop-usertoken='{"userToken":"huang-shu-chao-49"}' data-zop='{"authorName":"la vie","itemId":75629282,"title":"《快速掌握PyQt5》第二十章 列表视图、树形视图、表格视图","type":"article"}' data-za-detail-view-path-module=PostItem data-za-extra-module='{"card":{"content":{"type":"Post","token":"75629282"}}}'><div class=ColumnPageHeader-Wrapper><div><div class="Sticky ColumnPageHeader css-1l12z7y"><div class=ColumnPageHeader-content><a href=https://www.zhihu.com/ aria-label=知乎><svg viewBox="0 0 64 30" fill=#056DE8 width=64 height=30 class=css-1hlrcxk><path d="M29.05 4.582H16.733V25.94h3.018l.403 2.572 4.081-2.572h4.815V4.582zm-5.207 18.69l-2.396 1.509-.235-1.508h-1.724V7.233h6.78v16.04h-2.425zM14.46 14.191H9.982c0-.471.033-.954.039-1.458v-5.5h5.106V5.935a1.352 1.352 0 0 0-.404-.957 1.378 1.378 0 0 0-.968-.396H5.783c.028-.088.056-.177.084-.255.274-.82 1.153-3.326 1.153-3.326a4.262 4.262 0 0 0-2.413.698c-.57.4-.912.682-1.371 1.946-.532 1.453-.997 2.856-1.31 3.693C1.444 8.674.28 11.025.28 11.025a5.85 5.85 0 0 0 2.52-.61c1.119-.593 1.679-1.502 2.054-2.883l.09-.3h2.334v5.5c0 .5-.045.982-.073 1.46h-4.12c-.71 0-1.39.278-1.893.775a2.638 2.638 0 0 0-.783 1.874h6.527a17.717 17.717 0 0 1-.778 3.649 16.796 16.796 0 0 1-3.012 5.273A33.104 33.104 0 0 1 0 28.74s3.13 1.175 5.425-.954c1.388-1.292 2.631-3.814 3.23-5.727a28.09 28.09 0 0 0 1.12-5.229h5.967v-1.37a1.254 1.254 0 0 0-.373-.899 1.279 1.279 0 0 0-.909-.37z"></path><path d="M11.27 19.675l-2.312 1.491 5.038 7.458a6.905 6.905 0 0 0 .672-2.218 3.15 3.15 0 0 0-.28-2.168l-3.118-4.563zM51.449 15.195V5.842c4.181-.205 7.988-.405 9.438-.483l.851-.05c.387-.399.885-2.395.689-3.021-.073-.25-.213-.666-.638-.555a33.279 33.279 0 0 1-4.277.727c-2.766.321-3.97.404-7.804.682-6.718.487-12.709.72-12.709.72a2.518 2.518 0 0 0 .788 1.834 2.567 2.567 0 0 0 1.883.706c2.278-.095 5.598-.25 8.996-.41v9.203h-12.78c0 .703.281 1.377.783 1.874a2.69 2.69 0 0 0 1.892.777h10.105v7.075c0 .887-.464 1.192-1.231 1.214h-3.92a4.15 4.15 0 0 0 .837 1.544 4.2 4.2 0 0 0 1.403 1.067 6.215 6.215 0 0 0 2.71.277c1.36-.066 2.967-.826 2.967-3.57v-7.607h11.28c.342 0 .67-.135.91-.374.242-.239.378-.563.378-.902v-1.375H51.449z"></path><path d="M42.614 8.873a2.304 2.304 0 0 0-1.508-.926 2.334 2.334 0 0 0-1.727.405l-.376.272 4.255 5.85 2.24-1.62-2.884-3.98zM57.35 8.68l-3.125 4.097 2.24 1.663 4.517-5.927-.375-.277a2.32 2.32 0 0 0-1.722-.452 2.327 2.327 0 0 0-1.536.896z"></path></svg></a><i class=ColumnPageHeader-Line></i><div class=ColumnPageHeader-Title><div class=ColumnPageHeader-TitleName><span class=ColumnPageHeader-TitleMeta>首发于</span><a class="ColumnLink ColumnPageHeader-TitleColumn" href=https://www.zhihu.com/column/pyqt5>快速掌握PyQt5</a></div></div><div class=ColumnPageHeader-Button><div class=Popover><button title=更多 id=Popover1-toggle aria-haspopup=true aria-expanded=false aria-owns=Popover1-content type=button class="Button ColumnPageHeader-MenuToggler Button--plain"><svg width=24 height=24 viewBox="0 0 24 24" class="Zi Zi--Dots" fill=currentColor><path d="M5.34 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM13.665 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM21.99 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0Z"></path></svg></button></div><button type=button class="Button ColumnPageHeader-WriteButton Button--blue"><svg width=24 height=24 viewBox="0 0 24 24" class="Zi Zi--EditSurround" fill=currentColor><path fill-rule=evenodd d="M3.55 5.97a2.415 2.415 0 0 1 2.415-2.416h7.56a.75.75 0 0 1 0 1.5h-7.56a.915.915 0 0 0-.915.915v12.072c0 .505.41.915.915.915h12.074c.506 0 .915-.41.915-.915v-7.557a.75.75 0 0 1 1.5 0v7.557a2.415 2.415 0 0 1-2.415 2.415H5.965A2.415 2.415 0 0 1 3.55 18.04V5.969Z" clip-rule=evenodd></path><path fill-rule=evenodd d="M20.239 3.77a.75.75 0 0 1 0 1.06l-8.206 8.206a.75.75 0 0 1-1.06-1.06l8.205-8.206a.75.75 0 0 1 1.06 0Z" clip-rule=evenodd></path></svg>写文章</button></div></div><div class=ColumnPageHeader-profile><div class="Popover AppHeader-menu"><button id=Popover4-toggle aria-haspopup=true aria-expanded=false aria-owns=Popover4-content type=button class="Button AppHeader-profileEntry Button--plain"><img class="Avatar AppHeader-profileAvatar css-1tzrnvf" src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50"><rect fill-opacity="0"/></svg>' srcset alt=点击打开黄掌柜的主页 style="background-blend-mode:normal!important;background-clip:content-box!important;background-position:50% 50%!important;background-color:rgb(255,255,255)!important;background-image:var(--sf-img-5)!important;background-size:100% 100%!important;background-origin:content-box!important;background-repeat:no-repeat!important" sizes></button></div><div class="Popover AppHeaderProfileMenu-creatorHintPopover"><div class=AppHeaderProfileMenu-creatorHintToggler id=Popover5-toggle aria-haspopup=true aria-expanded=false aria-owns=Popover5-content></div></div></div></div></div></div><div class=css-78p1r9><div class=css-1oljx3p><div class=css-1ld0bim><img src="" alt="《快速掌握PyQt5》第二十章 列表视图、树形视图、表格视图" class=css-1phd9a0 srcset loading=lazy sizes width=100% height=100%></div></div></div><article class="Post-Main Post-NormalMain" tabindex=-1><header class=Post-Header><h1 class=Post-Title>《快速掌握PyQt5》第二十章 列表视图、树形视图、表格视图</h1><div class=Post-Author><div class=AuthorInfo itemprop=author itemscope itemtype=http://schema.org/Person><div class=AuthorInfo><span class="UserLink AuthorInfo-avatarWrapper"><div class=css-1gomreu><a href=https://www.zhihu.com/people/la-vie-est-belle target=_blank class=UserLink-link data-za-detail-view-element_name=User><img class="Avatar AuthorInfo-avatar css-1y9jkzv" src="" srcset alt="la vie" sizes></a></div></span><div class=AuthorInfo-content><div class=AuthorInfo-head><span class="UserLink AuthorInfo-name"><div class=css-1gomreu><a href=https://www.zhihu.com/people/la-vie-est-belle target=_blank class=UserLink-link data-za-detail-view-element_name=User>la vie</a></div></span></div><div class=AuthorInfo-detail><div class=AuthorInfo-badge><div class="ztext AuthorInfo-badgeText css-0">仰望星空，以梦为马。</div></div></div></div></div></div><button type=button class="Button FollowButton Button--primary Button--blue"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="Zi Zi--Plus FollowButton-icon" fill=currentColor><path fill-rule=evenodd d="M13.25 3.25a1.25 1.25 0 1 0-2.5 0v7.5h-7.5a1.25 1.25 0 1 0 0 2.5h7.5v7.5a1.25 1.25 0 1 0 2.5 0v-7.5h7.5a1.25 1.25 0 0 0 0-2.5h-7.5v-7.5Z" clip-rule=evenodd></path></svg></span>关注他</button></div><div class=LabelContainer-wrapper></div><div role=button tabindex=0><span class=Voters><button type=button class="Button Button--plain">21 人赞同了该文章</button></span></div></header><div class=Post-RichTextContainer><div class=css-1yuhvjn><div class=css-79elbk><div class="RichText ztext Post-RichText css-4em6pe" options="[object Object]"><p data-first-child data-pid=NIjZfZfi>在前一张所讲的列表控件QListWidget，树形控件QTreeWidget和表格控件QTableWidget是基于项(item-based)的控件，它们分别与QListWidgetItem，QTreeWidgetItem以及QTableWidgetItem一起使用。在基于项的控件中，数据是存储于项中再由对应的控件添加进去并显示的。而我们这章所讲的列表视图QListView，树形视图QTreeView和表格视图QTableView是基于模型的(model-based)，也就是说有关数据的获取或者存储操作都是跟模型有关。当我们在处理大量数据的时候，采用基于模型的控件可以让程序的处理速度更快，性能更好。<p class=ztext-empty-paragraph><br><p data-pid=7zZ-rKTA>需要一提的是QListView，QTreeView和QTableView分别是QListWidget，QTreeWidget和QTableWidget的父类，后三者的目的主要是为了使用方便，让开发更加快速(准确来说后三者也可以是视图，不过笔者还是习惯将前三者称作视图，后三者称为控件，比较好区分)。在高端复杂的程序中，还是建议使用前三者。<p class=ztext-empty-paragraph><br><p data-pid=jSi8sUwt>在分别讲解三个视图前，我们先来了解一下PyQt5中所提供的模型种类及用处：<figure data-size=normal><noscript class=sf-hidden><img src="https://pic2.zhimg.com/v2-8c0d6103bce1db47c594dac1e9cbbed9_b.jpg" data-caption="" data-size="normal" data-rawwidth="514" data-rawheight="283" class="origin_image zh-lightbox-thumb" data-original="https://pic2.zhimg.com/v2-8c0d6103bce1db47c594dac1e9cbbed9_r.jpg" width="514"></noscript><div><img src="" data-caption data-size=normal data-rawwidth=514 data-rawheight=283 class="origin_image zh-lightbox-thumb lazy" data-original=https://pic2.zhimg.com/v2-8c0d6103bce1db47c594dac1e9cbbed9_r.jpg data-actualsrc=https://pic2.zhimg.com/v2-8c0d6103bce1db47c594dac1e9cbbed9_b.jpg data-lazy-status=ok width=514 height=283></div></figure><p data-pid=yJzKLXtM>接下来我们结合模型和视图进行讲解(有关SQL的模型会在讲解数据库时再涉及)。<h2>20.1 列表视图QListView</h2><p data-pid=KnUYHJaZ> 我们用QStringListModel和QListView来实现前一章中讲解QListWidget时所完成的程序：<div class=highlight><pre><code class=language-python><span class=kn>import</span> <span class=nn>sys</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtGui</span> <span class=kn>import</span> <span class=n>QPixmap</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtCore</span> <span class=kn>import</span> <span class=n>QStringListModel</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtWidgets</span> <span class=kn>import</span> <span class=n>QApplication</span><span class=p>,</span> <span class=n>QWidget</span><span class=p>,</span> <span class=n>QListView</span><span class=p>,</span> <span class=n>QLabel</span><span class=p>,</span> <span class=n>QHBoxLayout</span><span class=p>,</span> <span class=n>QAbstractItemView</span>


<span class=k>class</span> <span class=nc>Demo</span><span class=p>(</span><span class=n>QWidget</span><span class=p>):</span>
    <span class=k>def</span> <span class=fm>__init__</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
        <span class=nb>super</span><span class=p>(</span><span class=n>Demo</span><span class=p>,</span> <span class=bp>self</span><span class=p>)</span><span class=o>.</span><span class=fm>__init__</span><span class=p>()</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>item_list</span> <span class=o>=</span> <span class=p>[</span><span class=s1>'item </span><span class=si>%s</span><span class=s1>'</span> <span class=o>%</span> <span class=n>i</span> <span class=k>for</span> <span class=n>i</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=mi>11</span><span class=p>)]</span>         <span class=c1># 1</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>model_1</span> <span class=o>=</span> <span class=n>QStringListModel</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>model_1</span><span class=o>.</span><span class=n>setStringList</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>item_list</span><span class=p>)</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>model_2</span> <span class=o>=</span> <span class=n>QStringListModel</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                       <span class=c1># 2</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span> <span class=o>=</span> <span class=n>QListView</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                           <span class=c1># 3</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span><span class=o>.</span><span class=n>setModel</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>model_1</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span><span class=o>.</span><span class=n>setEditTriggers</span><span class=p>(</span><span class=n>QAbstractItemView</span><span class=o>.</span><span class=n>NoEditTriggers</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span><span class=o>.</span><span class=n>doubleClicked</span><span class=o>.</span><span class=n>connect</span><span class=p>(</span><span class=k>lambda</span><span class=p>:</span> <span class=bp>self</span><span class=o>.</span><span class=n>change_func</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span><span class=p>))</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>listview_2</span> <span class=o>=</span> <span class=n>QListView</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                           <span class=c1># 4</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>listview_2</span><span class=o>.</span><span class=n>setModel</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>model_2</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>listview_2</span><span class=o>.</span><span class=n>setEditTriggers</span><span class=p>(</span><span class=n>QAbstractItemView</span><span class=o>.</span><span class=n>NoEditTriggers</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>listview_2</span><span class=o>.</span><span class=n>doubleClicked</span><span class=o>.</span><span class=n>connect</span><span class=p>(</span><span class=k>lambda</span><span class=p>:</span> <span class=bp>self</span><span class=o>.</span><span class=n>change_func</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>listview_2</span><span class=p>))</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>pic_label</span> <span class=o>=</span> <span class=n>QLabel</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                               <span class=c1># 5</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>pic_label</span><span class=o>.</span><span class=n>setPixmap</span><span class=p>(</span><span class=n>QPixmap</span><span class=p>(</span><span class=s1>'arrow.png'</span><span class=p>))</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>h_layout</span> <span class=o>=</span> <span class=n>QHBoxLayout</span><span class=p>()</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>h_layout</span><span class=o>.</span><span class=n>addWidget</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>h_layout</span><span class=o>.</span><span class=n>addWidget</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>pic_label</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>h_layout</span><span class=o>.</span><span class=n>addWidget</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>listview_2</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>setLayout</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>h_layout</span><span class=p>)</span>

    <span class=k>def</span> <span class=nf>change_func</span><span class=p>(</span><span class=bp>self</span><span class=p>,</span> <span class=n>listview</span><span class=p>):</span>                                
        <span class=k>if</span> <span class=n>listview</span> <span class=o>==</span> <span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span><span class=p>:</span>                             <span class=c1># 6</span>
            <span class=bp>self</span><span class=o>.</span><span class=n>model_2</span><span class=o>.</span><span class=n>insertRows</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>model_2</span><span class=o>.</span><span class=n>rowCount</span><span class=p>(),</span> <span class=mi>1</span><span class=p>)</span>

            <span class=n>data</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>listview_1</span><span class=o>.</span><span class=n>currentIndex</span><span class=p>()</span><span class=o>.</span><span class=n>data</span><span class=p>()</span>
            <span class=n>index</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>model_2</span><span class=o>.</span><span class=n>index</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>model_2</span><span class=o>.</span><span class=n>rowCount</span><span class=p>()</span><span class=o>-</span><span class=mi>1</span><span class=p>)</span>
            <span class=bp>self</span><span class=o>.</span><span class=n>model_2</span><span class=o>.</span><span class=n>setData</span><span class=p>(</span><span class=n>index</span><span class=p>,</span> <span class=n>data</span><span class=p>)</span>
        <span class=k>else</span><span class=p>:</span>                                                       <span class=c1># 7</span>
            <span class=bp>self</span><span class=o>.</span><span class=n>model_2</span><span class=o>.</span><span class=n>removeRows</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>listview_2</span><span class=o>.</span><span class=n>currentIndex</span><span class=p>()</span><span class=o>.</span><span class=n>row</span><span class=p>(),</span> <span class=mi>1</span><span class=p>)</span>


<span class=k>if</span> <span class=vm>__name__</span> <span class=o>==</span> <span class=s1>'__main__'</span><span class=p>:</span>
    <span class=n>app</span> <span class=o>=</span> <span class=n>QApplication</span><span class=p>(</span><span class=n>sys</span><span class=o>.</span><span class=n>argv</span><span class=p>)</span>
    <span class=n>demo</span> <span class=o>=</span> <span class=n>Demo</span><span class=p>()</span>
    <span class=n>demo</span><span class=o>.</span><span class=n>show</span><span class=p>()</span>
    <span class=n>sys</span><span class=o>.</span><span class=n>exit</span><span class=p>(</span><span class=n>app</span><span class=o>.</span><span class=n>exec_</span><span class=p>())</span></code></pre></div><p data-pid=39dMnVeq>1. 首先用列表推导式生成11个item，然后实例化一个QStringListModel并用setStringList(iterable)方法将数据添加到到模型中；<p data-pid=YqwzHgxw>2. model_1用于listview_1，model_2用于listview_2；<p data-pid=kUm6Vtfg>3. 实例化一个列表视图listview_1，并调用setModel(model)方法将model_1作为参数传入，此时，列表视图就会显示出模型中的数据，模型数据发生任何改变，视图也会自动作出相应改变。setEditTriggers()方法可设置视图的编辑规则，可传入的参数如下(当然QListWidget也有相同方法)：<figure data-size=normal><noscript class=sf-hidden><img src="https://pic2.zhimg.com/v2-3976fa2adab5f288325b7d7d4b8ac081_b.jpg" data-caption="" data-size="normal" data-rawwidth="861" data-rawheight="321" class="origin_image zh-lightbox-thumb" data-original="https://pic2.zhimg.com/v2-3976fa2adab5f288325b7d7d4b8ac081_r.jpg" width="861"></noscript><div><img src= data-caption data-size=normal data-rawwidth=861 data-rawheight=321 class="origin_image zh-lightbox-thumb lazy" data-original=https://pic2.zhimg.com/v2-3976fa2adab5f288325b7d7d4b8ac081_r.jpg data-actualsrc=https://pic2.zhimg.com/v2-3976fa2adab5f288325b7d7d4b8ac081_b.jpg data-lazy-status=ok width=861 height=321></div></figure><p data-pid=OJ-ljsAz>接着我们将视图的doubleClicked信号与自定义的槽函数change_func()连接了起来；<p data-pid=6ZqMq6T9>4. 同理，实例化一个listview_2，设置模型和编辑规则并将信号和槽函数进行连接；<p data-pid=APRU4CMv>5. pic_label用于显示图片；<p data-pid=2u_CdpnM>6. 在槽函数中我们判断触发doubleClicked信号的视图，如果是listview_1的话，则我们通过insertRows(int, int)方法先在model_2中插入一个空行，该方法的第一个参数为行序号，即要将数据插入哪一行，第二个为要插入的行数量。在这里rowCount()方法获取总行数(在这里正好可以当做行序号，表示我们将新行添加到最后一行)，1表示我们在每次双击时都只插入一行。<p data-pid=HwZ94NIm>由于插入的只是空行，所以我们要调用setData(QModelindex, data)方法将该空行设为相应的内容。通过currentIndex().data()方法可以获取到被双击行的数据，比如双击在'Item 0'上，那么我们就获取了‘Item 0’这个文本。而调用QStringListModel的index(int)方法获取到指定的QModelIndex，传入的参数为行序号(请注意序号都是从0开始计算)；<p data-pid=UMWKflMN>7. 如果是listview_2触发doubleClicked信号的话，那我们就通过调用removeRows(int, int)，方法将被双击的行给删除掉。currentIndex().row()方法获取被双击行的行序号，1表示我们只删除一行。<p class=ztext-empty-paragraph><br><p data-pid=xMSCEVDC>运行截图如下，在左边视图双击可将相应行数据添加到右边视图：<figure data-size=normal><noscript class=sf-hidden><img src="https://pic1.zhimg.com/v2-d3fed01df255ca3f779dead1d56faff0_b.jpg" data-caption="" data-size="normal" data-rawwidth="1268" data-rawheight="508" class="origin_image zh-lightbox-thumb" data-original="https://pic1.zhimg.com/v2-d3fed01df255ca3f779dead1d56faff0_r.jpg" width="1268"></noscript><div><img src="" data-caption data-size=normal data-rawwidth=1268 data-rawheight=508 class="origin_image zh-lightbox-thumb lazy" data-original=https://pic1.zhimg.com/v2-d3fed01df255ca3f779dead1d56faff0_r.jpg data-actualsrc=https://pic1.zhimg.com/v2-d3fed01df255ca3f779dead1d56faff0_b.jpg data-lazy-status=ok width=1268 height=508></div></figure><p data-pid=q10qKU05>双击右边视图中的行可进行删除：<figure data-size=normal><noscript class=sf-hidden><img src="https://pic2.zhimg.com/v2-fa53814fb28137d1ecccf8f7f9d22e4d_b.jpg" data-caption="" data-size="normal" data-rawwidth="1268" data-rawheight="508" class="origin_image zh-lightbox-thumb" data-original="https://pic2.zhimg.com/v2-fa53814fb28137d1ecccf8f7f9d22e4d_r.jpg" width="1268"></noscript><div><img src="" data-caption data-size=normal data-rawwidth=1268 data-rawheight=508 class="origin_image zh-lightbox-thumb lazy" data-original=https://pic2.zhimg.com/v2-fa53814fb28137d1ecccf8f7f9d22e4d_r.jpg data-actualsrc=https://pic2.zhimg.com/v2-fa53814fb28137d1ecccf8f7f9d22e4d_b.jpg data-lazy-status=ok width=1268 height=508></div></figure><h2>​20.2 树形视图QTreeView</h2><p data-pid=ZkY36Q-B>树形视图常被用来显示文件目录：<div class=highlight><pre><code class=language-python><span class=kn>import</span> <span class=nn>sys</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtCore</span> <span class=kn>import</span> <span class=n>QDir</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtWidgets</span> <span class=kn>import</span> <span class=n>QApplication</span><span class=p>,</span> <span class=n>QWidget</span><span class=p>,</span> <span class=n>QTreeView</span><span class=p>,</span> <span class=n>QDirModel</span><span class=p>,</span> <span class=n>QLabel</span><span class=p>,</span> <span class=n>QVBoxLayout</span>


<span class=k>class</span> <span class=nc>Demo</span><span class=p>(</span><span class=n>QWidget</span><span class=p>):</span>
    <span class=k>def</span> <span class=fm>__init__</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
        <span class=nb>super</span><span class=p>(</span><span class=n>Demo</span><span class=p>,</span> <span class=bp>self</span><span class=p>)</span><span class=o>.</span><span class=fm>__init__</span><span class=p>()</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>resize</span><span class=p>(</span><span class=mi>600</span><span class=p>,</span> <span class=mi>300</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>model</span> <span class=o>=</span> <span class=n>QDirModel</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                            <span class=c1># 1</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>setReadOnly</span><span class=p>(</span><span class=bp>False</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>setSorting</span><span class=p>(</span><span class=n>QDir</span><span class=o>.</span><span class=n>Name</span> <span class=o>|</span> <span class=n>QDir</span><span class=o>.</span><span class=n>IgnoreCase</span><span class=p>)</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>tree</span> <span class=o>=</span> <span class=n>QTreeView</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                             <span class=c1># 2</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>tree</span><span class=o>.</span><span class=n>setModel</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>tree</span><span class=o>.</span><span class=n>clicked</span><span class=o>.</span><span class=n>connect</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>show_info</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>index</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>index</span><span class=p>(</span><span class=n>QDir</span><span class=o>.</span><span class=n>currentPath</span><span class=p>())</span>       
        <span class=bp>self</span><span class=o>.</span><span class=n>tree</span><span class=o>.</span><span class=n>expand</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>index</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>tree</span><span class=o>.</span><span class=n>scrollTo</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>index</span><span class=p>)</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>info_label</span> <span class=o>=</span> <span class=n>QLabel</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                          <span class=c1># 3</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span> <span class=o>=</span> <span class=n>QVBoxLayout</span><span class=p>()</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span><span class=o>.</span><span class=n>addWidget</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>tree</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span><span class=o>.</span><span class=n>addWidget</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>info_label</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>setLayout</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span><span class=p>)</span>

    <span class=k>def</span> <span class=nf>show_info</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>                                        <span class=c1># 4</span>
        <span class=n>index</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>tree</span><span class=o>.</span><span class=n>currentIndex</span><span class=p>()</span>
        <span class=n>file_name</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>fileName</span><span class=p>(</span><span class=n>index</span><span class=p>)</span>
        <span class=n>file_path</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>filePath</span><span class=p>(</span><span class=n>index</span><span class=p>)</span>
        <span class=n>file_info</span> <span class=o>=</span> <span class=s1>'File Name: {}</span><span class=se>\n</span><span class=s1>File Path: {}'</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>file_name</span><span class=p>,</span> <span class=n>file_path</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>info_label</span><span class=o>.</span><span class=n>setText</span><span class=p>(</span><span class=n>file_info</span><span class=p>)</span>


<span class=k>if</span> <span class=vm>__name__</span> <span class=o>==</span> <span class=s1>'__main__'</span><span class=p>:</span>
    <span class=n>app</span> <span class=o>=</span> <span class=n>QApplication</span><span class=p>(</span><span class=n>sys</span><span class=o>.</span><span class=n>argv</span><span class=p>)</span>
    <span class=n>demo</span> <span class=o>=</span> <span class=n>Demo</span><span class=p>()</span>
    <span class=n>demo</span><span class=o>.</span><span class=n>show</span><span class=p>()</span>
    <span class=n>sys</span><span class=o>.</span><span class=n>exit</span><span class=p>(</span><span class=n>app</span><span class=o>.</span><span class=n>exec_</span><span class=p>())</span></code></pre></div><p data-pid=6A5qg9he>1. 实例化一个QDirModel，通过setReadOnly(False)方法可以让我们在QTreeView中直接对文件进行编辑，若设为True，则表示只读模式。setSorting()方法可以让显示的文件或文件夹按照指定要求进行排序，可传入的参数如下：<figure data-size=normal><noscript class=sf-hidden><img src="https://pic3.zhimg.com/v2-4ad0e928d31c10ee40f94016fbd27f9a_b.jpg" data-caption="" data-size="normal" data-rawwidth="859" data-rawheight="477" class="origin_image zh-lightbox-thumb" data-original="https://pic3.zhimg.com/v2-4ad0e928d31c10ee40f94016fbd27f9a_r.jpg" width="859"></noscript><div><img src= data-caption data-size=normal data-rawwidth=859 data-rawheight=477 class="origin_image zh-lightbox-thumb lazy" data-original=https://pic3.zhimg.com/v2-4ad0e928d31c10ee40f94016fbd27f9a_r.jpg data-actualsrc=https://pic3.zhimg.com/v2-4ad0e928d31c10ee40f94016fbd27f9a_b.jpg data-lazy-status=ok width=859 height=477></div></figure><p data-pid=oVBKTMxU>2. 实例化一个树形视图，将其模型设为self.model。接着将clicked信号和自定义的槽函数连接起来。然后我们通过调用self.model的index()方法传入一个QDir.currentPath()来获取当前路径的QModelIndex索引值，再调用self.tree的expand()方法进行展开显示，scrollTo()方法则是将当前视图的视口滚动到self.index索引处。<p data-pid=gzJW8AtM>3. info_label用于显示文件信息；<p data-pid=tB-6eiI4>4. 在槽函数中，我们首先通过currentIndex()方法获取当前鼠标所点击的QModelIndex索引值，然后分别传入self.model的fileName()和filePath()函数中，最后用info_label显示出来：<p class=ztext-empty-paragraph><br><p data-pid=pB2Xjdf9>运行截图如下：<figure data-size=normal><noscript class=sf-hidden><img src="https://pic4.zhimg.com/v2-3a3bf5a0af23fa0b48333bae6cb40fc3_b.jpg" data-caption="" data-size="normal" data-rawwidth="1600" data-rawheight="644" class="origin_image zh-lightbox-thumb" data-original="https://pic4.zhimg.com/v2-3a3bf5a0af23fa0b48333bae6cb40fc3_r.jpg" width="1600"></noscript><div><img src="" data-caption data-size=normal data-rawwidth=1600 data-rawheight=644 class="origin_image zh-lightbox-thumb lazy" data-original=https://pic4.zhimg.com/v2-3a3bf5a0af23fa0b48333bae6cb40fc3_r.jpg data-actualsrc=https://pic4.zhimg.com/v2-3a3bf5a0af23fa0b48333bae6cb40fc3_b.jpg data-lazy-status=ok width=1600 height=644></div></figure><h2>​20.3 表格视图QTableView</h2><p data-pid=1xYABm1L>这里我们将QStandItemModel和QTableView搭配使用：<div class=highlight><pre><code class=language-python><span class=kn>import</span> <span class=nn>sys</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtCore</span> <span class=kn>import</span> <span class=n>Qt</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtGui</span> <span class=kn>import</span> <span class=n>QStandardItem</span><span class=p>,</span> <span class=n>QStandardItemModel</span>
<span class=kn>from</span> <span class=nn>PyQt5.QtWidgets</span> <span class=kn>import</span> <span class=n>QApplication</span><span class=p>,</span> <span class=n>QWidget</span><span class=p>,</span> <span class=n>QTableView</span><span class=p>,</span> <span class=n>QAbstractItemView</span><span class=p>,</span> <span class=n>QLabel</span><span class=p>,</span> <span class=n>QVBoxLayout</span>


<span class=k>class</span> <span class=nc>Demo</span><span class=p>(</span><span class=n>QWidget</span><span class=p>):</span>
    <span class=k>def</span> <span class=fm>__init__</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>
        <span class=nb>super</span><span class=p>(</span><span class=n>Demo</span><span class=p>,</span> <span class=bp>self</span><span class=p>)</span><span class=o>.</span><span class=fm>__init__</span><span class=p>()</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>resize</span><span class=p>(</span><span class=mi>650</span><span class=p>,</span> <span class=mi>300</span><span class=p>)</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>model</span> <span class=o>=</span> <span class=n>QStandardItemModel</span><span class=p>(</span><span class=mi>6</span><span class=p>,</span> <span class=mi>6</span><span class=p>,</span> <span class=bp>self</span><span class=p>)</span>            <span class=c1># 1</span>
        <span class=c1># self.model = QStandardItemModel(self)</span>
        <span class=c1># self.model.setColumnCount(6)</span>
        <span class=c1># self.model.setRowCount(6)</span>

        <span class=k>for</span> <span class=n>row</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=mi>6</span><span class=p>):</span>                                   <span class=c1># 2</span>
            <span class=k>for</span> <span class=n>column</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=mi>6</span><span class=p>):</span>
                <span class=n>item</span> <span class=o>=</span> <span class=n>QStandardItem</span><span class=p>(</span><span class=s1>'({}, {})'</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>row</span><span class=p>,</span> <span class=n>column</span><span class=p>))</span>
                <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>setItem</span><span class=p>(</span><span class=n>row</span><span class=p>,</span> <span class=n>column</span><span class=p>,</span> <span class=n>item</span><span class=p>)</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>item_list</span> <span class=o>=</span> <span class=p>[</span><span class=n>QStandardItem</span><span class=p>(</span><span class=s1>'(6, {})'</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>column</span><span class=p>))</span> <span class=k>for</span> <span class=n>column</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=mi>6</span><span class=p>)]</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>appendRow</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>item_list</span><span class=p>)</span>                   <span class=c1># 3</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>item_list</span> <span class=o>=</span> <span class=p>[</span><span class=n>QStandardItem</span><span class=p>(</span><span class=s1>'(7, {})'</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>column</span><span class=p>))</span> <span class=k>for</span> <span class=n>column</span> <span class=ow>in</span> <span class=nb>range</span><span class=p>(</span><span class=mi>6</span><span class=p>)]</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=o>.</span><span class=n>insertRow</span><span class=p>(</span><span class=mi>7</span><span class=p>,</span> <span class=bp>self</span><span class=o>.</span><span class=n>item_list</span><span class=p>)</span>                <span class=c1># 4</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>table</span> <span class=o>=</span> <span class=n>QTableView</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                          <span class=c1># 5</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=o>.</span><span class=n>setModel</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>model</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=o>.</span><span class=n>horizontalHeader</span><span class=p>()</span><span class=o>.</span><span class=n>setStretchLastSection</span><span class=p>(</span><span class=bp>True</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=o>.</span><span class=n>setEditTriggers</span><span class=p>(</span><span class=n>QAbstractItemView</span><span class=o>.</span><span class=n>NoEditTriggers</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=o>.</span><span class=n>clicked</span><span class=o>.</span><span class=n>connect</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>show_info</span><span class=p>)</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>info_label</span> <span class=o>=</span> <span class=n>QLabel</span><span class=p>(</span><span class=bp>self</span><span class=p>)</span>                         <span class=c1># 6</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>info_label</span><span class=o>.</span><span class=n>setAlignment</span><span class=p>(</span><span class=n>Qt</span><span class=o>.</span><span class=n>AlignCenter</span><span class=p>)</span>

        <span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span> <span class=o>=</span> <span class=n>QVBoxLayout</span><span class=p>()</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span><span class=o>.</span><span class=n>addWidget</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span><span class=o>.</span><span class=n>addWidget</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>info_label</span><span class=p>)</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>setLayout</span><span class=p>(</span><span class=bp>self</span><span class=o>.</span><span class=n>v_layout</span><span class=p>)</span>

    <span class=k>def</span> <span class=nf>show_info</span><span class=p>(</span><span class=bp>self</span><span class=p>):</span>                                       <span class=c1># 7</span>
        <span class=n>row</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=o>.</span><span class=n>currentIndex</span><span class=p>()</span><span class=o>.</span><span class=n>row</span><span class=p>()</span>
        <span class=n>column</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=o>.</span><span class=n>currentIndex</span><span class=p>()</span><span class=o>.</span><span class=n>column</span><span class=p>()</span>
        <span class=k>print</span><span class=p>(</span><span class=s1>'({}, {})'</span><span class=o>.</span><span class=n>format</span><span class=p>(</span><span class=n>row</span><span class=p>,</span> <span class=n>column</span><span class=p>))</span>

        <span class=n>data</span> <span class=o>=</span> <span class=bp>self</span><span class=o>.</span><span class=n>table</span><span class=o>.</span><span class=n>currentIndex</span><span class=p>()</span><span class=o>.</span><span class=n>data</span><span class=p>()</span>
        <span class=bp>self</span><span class=o>.</span><span class=n>info_label</span><span class=o>.</span><span class=n>setText</span><span class=p>(</span><span class=n>data</span><span class=p>)</span>


<span class=k>if</span> <span class=vm>__name__</span> <span class=o>==</span> <span class=s1>'__main__'</span><span class=p>:</span>
    <span class=n>app</span> <span class=o>=</span> <span class=n>QApplication</span><span class=p>(</span><span class=n>sys</span><span class=o>.</span><span class=n>argv</span><span class=p>)</span>
    <span class=n>demo</span> <span class=o>=</span> <span class=n>Demo</span><span class=p>()</span>
    <span class=n>demo</span><span class=o>.</span><span class=n>show</span><span class=p>()</span>
    <span class=n>sys</span><span class=o>.</span><span class=n>exit</span><span class=p>(</span><span class=n>app</span><span class=o>.</span><span class=n>exec_</span><span class=p>())</span></code></pre></div><p data-pid=vVOOhdEp>1. 实例化一个QStandItemModel，可直接在实例化时传入行数和列数，或者也可以通过setRowCount()和setColumn()方法来设置。<p data-pid=YmYBqnNj>2. QStandItemModel与QStandardItem搭配使用，这里通过循环实例化36个QStandardItem(每一个item代表一个单元格)，接着调用setItem()方法将每一个Item放在相应的位置；<p data-pid=oUrEawoW>3. appendRow()方法可以把新行添加到表格最后，也就是说目前有7行；<p data-pid=6_hcUfDR>4. insertRow()方法可以在指定方法添加一行，这里我们在最后一行插入一行，现在有8行；<p data-pid=xqGTxiB3>5. 实例化一个QTableView，设置模型。self.table.horizontalHeader().setStretchLastSection(True)可以让表格填满整个窗口，如果拉伸窗口的话则为了填满窗口表格最后列会改变尺寸。setEditTriggers()方法设置编辑规则，这里我们设置无法编辑。最后将clicked信号和自定义的槽函数连接起来；<p data-pid=KxdhFFlv>6. info_label用于显示单元格文本；<p data-pid=TWjnRTBR>7. currentIndex().row()可以获取当前点击单元格所在的行序号，currentIndex().column()可以获取当前点击单元格所在的列序号。currentIndex().data()可以获取到当前点击单元格的文本；<p class=ztext-empty-paragraph><br><p data-pid=AQ-GzWst>运行截图如下：<figure data-size=normal><noscript class=sf-hidden><img src="https://pic1.zhimg.com/v2-90de5cdb5a1ea8b822b89bcf7bba4678_b.jpg" data-caption="" data-size="normal" data-rawwidth="1300" data-rawheight="644" class="origin_image zh-lightbox-thumb" data-original="https://pic1.zhimg.com/v2-90de5cdb5a1ea8b822b89bcf7bba4678_r.jpg" width="1300"></noscript><div><img src= data-caption data-size=normal data-rawwidth=1300 data-rawheight=644 class="origin_image zh-lightbox-thumb lazy" data-original=https://pic1.zhimg.com/v2-90de5cdb5a1ea8b822b89bcf7bba4678_r.jpg data-actualsrc=https://pic1.zhimg.com/v2-90de5cdb5a1ea8b822b89bcf7bba4678_b.jpg data-lazy-status=ok width=1300 height=644></div></figure><p data-pid=XjA3mwe7>​<p data-pid=NAQNosWR>若要更加个性化地控制界面，请大家阅读：<div class=RichText-LinkCardContainer><a target=_blank href="https://link.zhihu.com/?target=https%3A//pyqt5.blog.csdn.net/article/details/107628599" data-draft-node=block data-draft-type=link-card data-text=《PyQt5高级编程实战》学会使用视图委托_la_vie_est_belle的博客-CSDN博客 class="LinkCard new css-1wr1m8" data-image=https://pic3.zhimg.com/v2-3d6f0b0cdd7632882b0ca6d20143ea66_ipico.jpg data-image-width=480 data-image-height=480 data-za-detail-view-id=172><span class=LinkCard-contents><span class="LinkCard-title two-line">《PyQt5高级编程实战》学会使用视图委托_la_vie_est_belle的博客-CSDN博客</span><span class=LinkCard-desc><span style=display:inline-flex;align-items:center>​<svg width=14 height=14 viewBox="0 0 24 24" class="Zi Zi--InsertLink" fill=currentColor><path fill-rule=evenodd d="M5.327 18.883a3.005 3.005 0 0 1 0-4.25l2.608-2.607a.75.75 0 1 0-1.06-1.06l-2.608 2.607a4.505 4.505 0 0 0 6.37 6.37l2.608-2.607a.75.75 0 0 0-1.06-1.06l-2.608 2.607a3.005 3.005 0 0 1-4.25 0Zm5.428-11.799a.75.75 0 0 0 1.06 1.06L14.48 5.48a3.005 3.005 0 0 1 4.25 4.25l-2.665 2.665a.75.75 0 0 0 1.061 1.06l2.665-2.664a4.505 4.505 0 0 0-6.371-6.372l-2.665 2.665Zm5.323 2.117a.75.75 0 1 0-1.06-1.06l-7.072 7.07a.75.75 0 0 0 1.061 1.06l7.071-7.07Z" clip-rule=evenodd></path></svg></span>pyqt5.blog.csdn.net/article/details/107628599</span></span><span class=LinkCard-image style=height:60px><img src="" alt></span></a></div><h2>20.4 小结</h2><p data-pid=8mVUq3qt>1. 注意本章示例的模型和视图搭配并不是固定的，比如QDirModel不是只能用于QTreeView，该模型当然也可以和其他两种视图搭配使用。<p data-pid=oxkTKDRI>2. QListWidget、QTreeWidget和QTableWidget分别是对QListView、QTreeView和QTableView封装后的简便类，所以前三者比后三者使用起来较为简单，不过后三者可以让程序在性能上更好，处理速度更快。<div class=RichText-ADLinkCardContainer><div class=FeeConsultCard><img src="" alt><div><div class=FeeConsultCard-name>la vie</div><div class=FeeConsultCard-times><svg width=24 height=24 viewBox="0 0 24 24" class="Zi Zi--CheckCircle" fill=currentColor><path fill-rule=evenodd d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-11.056 1.584-2.103-2.103a.75.75 0 0 0-1.06 1.06l2.628 2.63c.002 0 .003.003.005.004a.75.75 0 0 0 1.06 0l4.746-4.745a.75.75 0 0 0-1.061-1.06l-4.215 4.214Z" clip-rule=evenodd></path></svg><span>18 次咨询</span><div class=Stars><svg width=14 height=14 viewBox="0 0 24 24" fill=#FF9607 class="Zi Zi--Star"><path d="M10.484 3.307c.673-1.168 2.358-1.168 3.032 0l2.377 4.122a.25.25 0 0 0 .165.12l4.655.987c1.319.28 1.84 1.882.937 2.884l-3.186 3.535a.25.25 0 0 0-.063.193l.5 4.733c.142 1.34-1.222 2.33-2.453 1.782l-4.346-1.938a.25.25 0 0 0-.204 0l-4.346 1.938c-1.231.549-2.595-.442-2.453-1.782l.5-4.733a.25.25 0 0 0-.064-.193L2.35 11.42c-.903-1.002-.382-2.604.937-2.884l4.655-.987a.25.25 0 0 0 .164-.12l2.378-4.122Z"></path></svg><svg width=14 height=14 viewBox="0 0 24 24" fill=#FF9607 class="Zi Zi--Star"><path d="M10.484 3.307c.673-1.168 2.358-1.168 3.032 0l2.377 4.122a.25.25 0 0 0 .165.12l4.655.987c1.319.28 1.84 1.882.937 2.884l-3.186 3.535a.25.25 0 0 0-.063.193l.5 4.733c.142 1.34-1.222 2.33-2.453 1.782l-4.346-1.938a.25.25 0 0 0-.204 0l-4.346 1.938c-1.231.549-2.595-.442-2.453-1.782l.5-4.733a.25.25 0 0 0-.064-.193L2.35 11.42c-.903-1.002-.382-2.604.937-2.884l4.655-.987a.25.25 0 0 0 .164-.12l2.378-4.122Z"></path></svg><svg width=14 height=14 viewBox="0 0 24 24" fill=#FF9607 class="Zi Zi--Star"><path d="M10.484 3.307c.673-1.168 2.358-1.168 3.032 0l2.377 4.122a.25.25 0 0 0 .165.12l4.655.987c1.319.28 1.84 1.882.937 2.884l-3.186 3.535a.25.25 0 0 0-.063.193l.5 4.733c.142 1.34-1.222 2.33-2.453 1.782l-4.346-1.938a.25.25 0 0 0-.204 0l-4.346 1.938c-1.231.549-2.595-.442-2.453-1.782l.5-4.733a.25.25 0 0 0-.064-.193L2.35 11.42c-.903-1.002-.382-2.604.937-2.884l4.655-.987a.25.25 0 0 0 .164-.12l2.378-4.122Z"></path></svg><svg width=14 height=14 viewBox="0 0 24 24" fill=#FF9607 class="Zi Zi--Star"><path d="M10.484 3.307c.673-1.168 2.358-1.168 3.032 0l2.377 4.122a.25.25 0 0 0 .165.12l4.655.987c1.319.28 1.84 1.882.937 2.884l-3.186 3.535a.25.25 0 0 0-.063.193l.5 4.733c.142 1.34-1.222 2.33-2.453 1.782l-4.346-1.938a.25.25 0 0 0-.204 0l-4.346 1.938c-1.231.549-2.595-.442-2.453-1.782l.5-4.733a.25.25 0 0 0-.064-.193L2.35 11.42c-.903-1.002-.382-2.604.937-2.884l4.655-.987a.25.25 0 0 0 .164-.12l2.378-4.122Z"></path></svg><svg width=14 height=14 viewBox="0 0 24 24" fill=#D3D3D3 class="Zi Zi--Star"><path d="M10.484 3.307c.673-1.168 2.358-1.168 3.032 0l2.377 4.122a.25.25 0 0 0 .165.12l4.655.987c1.319.28 1.84 1.882.937 2.884l-3.186 3.535a.25.25 0 0 0-.063.193l.5 4.733c.142 1.34-1.222 2.33-2.453 1.782l-4.346-1.938a.25.25 0 0 0-.204 0l-4.346 1.938c-1.231.549-2.595-.442-2.453-1.782l.5-4.733a.25.25 0 0 0-.064-.193L2.35 11.42c-.903-1.002-.382-2.604.937-2.884l4.655-.987a.25.25 0 0 0 .164-.12l2.378-4.122Z"></path></svg><span style=color:rgb(255,150,7);font-size:13px>4.8</span></div></div><div class=FeeConsultCard-like><svg width=24 height=24 viewBox="0 0 24 24" class="Zi Zi--Like" fill=currentColor><path d="M8.5 4.078c0-1.834 1.986-2.979 3.573-2.06a4.826 4.826 0 0 1 2.379 4.71l-.114 1.022h3.581c2.53 0 4.334 2.454 3.58 4.868l-1.823 5.833a3.784 3.784 0 0 1-3.848 2.64c-2.372-.147-6.042-.341-8.828-.341H4.5A1.75 1.75 0 0 1 2.75 19V9.5c0-.967.784-1.75 1.75-1.75h.637a3.418 3.418 0 0 0 3.19-2.191c.115-.296.173-.611.173-.928v-.553Z"></path></svg>2510 次赞同</div></div><div class=FeeConsultCard-fee style=bottom:12px>去咨询<svg width=24 height=24 viewBox="0 0 24 24" class="Zi Zi--ArrowRight" fill=currentColor><path fill-rule=evenodd d="m13.248 12-4.025 3.78a.684.684 0 0 0 0 1.01.796.796 0 0 0 1.075 0l4.42-4.15a.867.867 0 0 0 0-1.28l-4.42-4.15a.796.796 0 0 0-1.075 0 .684.684 0 0 0 0 1.01L13.248 12Z" clip-rule=evenodd></path></svg></div></div></div><p></p></div></div></div></div><div role=button tabindex=0 class=ContentItem-time>发布于 2019-07-29 11:23</div><div class=Reward><div><div class=Reward-tagline>「谢谢支持」</div><button class=Reward-rewardBtn>赞赏</button></div><div class=Reward-countZero>还没有人赞赏，快来当第一个赞赏的人吧！</div></div><div class=Post-topicsAndReviewer><div class="TopicList Post-Topics"><div class="Tag Topic css-1s3a4zw" data-za-detail-view-path-module=TopicItem data-za-extra-module='{"card":{"content":{"type":"Topic","token":"19701025"}}}'><span class=Tag-content><a class=TopicLink href=https://www.zhihu.com/topic/19701025 target=_blank><div class=css-1gomreu>PyQt</div></a></span></div><div class="Tag Topic css-1s3a4zw" data-za-detail-view-path-module=TopicItem data-za-extra-module='{"card":{"content":{"type":"Topic","token":"20102824"}}}'><span class=Tag-content><a class=TopicLink href=https://www.zhihu.com/topic/20102824 target=_blank><div class=css-1gomreu>PyQt5</div></a></span></div><div class="Tag Topic css-1s3a4zw" data-za-detail-view-path-module=TopicItem data-za-extra-module='{"card":{"content":{"type":"Topic","token":"19552832"}}}'><span class=Tag-content><a class=TopicLink href=https://www.zhihu.com/topic/19552832 target=_blank><div class=css-1gomreu>Python</div></a></span></div></div></div><div><div class="Sticky RichContent-actions is-bottom"><div class=ContentItem-actions data-za-detail-view-path-module=BottomBar data-za-extra-module='{"card":{"content":{"type":"Post","id":"75629282"}}}'><span><button aria-label="赞同 21 " aria-live=polite type=button class="Button VoteButton VoteButton--up"><span style=display:inline-flex;align-items:center>​<svg width=10 height=10 viewBox="0 0 24 24" class="Zi Zi--TriangleUp VoteButton-TriangleUp" fill=currentColor><path fill-rule=evenodd d="M13.792 3.681c-.781-1.406-2.803-1.406-3.584 0l-7.79 14.023c-.76 1.367.228 3.046 1.791 3.046h15.582c1.563 0 2.55-1.68 1.791-3.046l-7.79-14.023Z" clip-rule=evenodd></path></svg></span>赞同 21</button><button aria-label=反对 aria-live=polite type=button class="Button VoteButton VoteButton--down"><span style=display:inline-flex;align-items:center>​<svg width=10 height=10 viewBox="0 0 24 24" class="Zi Zi--TriangleDown" fill=currentColor><path fill-rule=evenodd d="M13.792 20.319c-.781 1.406-2.803 1.406-3.584 0L2.418 6.296c-.76-1.367.228-3.046 1.791-3.046h15.582c1.563 0 2.55 1.68 1.791 3.046l-7.79 14.023Z" clip-rule=evenodd></path></svg></span></button></span><button type=button class="Button BottomActions-CommentBtn Button--plain Button--withIcon Button--withLabel"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="Zi Zi--Comment Button-zi" fill=currentColor><path fill-rule=evenodd d="M12 2.75a9.25 9.25 0 1 0 4.737 17.197l2.643.817a1 1 0 0 0 1.25-1.25l-.8-2.588A9.25 9.25 0 0 0 12 2.75Z" clip-rule=evenodd></path></svg></span>3 条评论</button><div class="Popover ShareMenu"><div class=ShareMenu-toggler id=Popover2-toggle aria-haspopup=true aria-expanded=false aria-owns=Popover2-content><button type=button class="Button Button--plain Button--withIcon Button--withLabel"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="Zi Zi--Share Button-zi" fill=currentColor><path d="M19.47 1.914a.8.8 0 0 1 1.204.778l-1.872 16.386a.9.9 0 0 1-1.204.743l-4.615-1.692a.7.7 0 0 0-.831.28l-1.927 3.02c-.43.674-1.474.369-1.474-.43v-3.865a.8.8 0 0 1 .179-.504l5.808-7.148a.595.595 0 0 0-.897-.781l-5.93 6.354a1.1 1.1 0 0 1-1.258.252L2.57 13.46a.8.8 0 0 1-.08-1.415l16.98-10.13Z"></path></svg></span>分享</button></div></div><button aria-live=polite type=button class="Button ContentItem-action Button--plain Button--withIcon Button--withLabel"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="Zi Zi--Heart Button-zi" fill=currentColor><path fill-rule=evenodd d="M12.004 4.934c1.015-.944 2.484-1.618 3.98-1.618 3.48 0 6.53 3.265 6.15 7.614-.11 1.254-.686 2.55-1.458 3.753-.778 1.215-1.79 2.392-2.845 3.419-1.054 1.028-2.168 1.923-3.161 2.566a9.96 9.96 0 0 1-1.41.777c-.418.182-.862.32-1.268.32s-.848-.137-1.267-.317a9.918 9.918 0 0 1-1.407-.771c-.992-.64-2.103-1.53-3.156-2.555-1.052-1.024-2.062-2.2-2.84-3.417-.77-1.208-1.346-2.51-1.456-3.775-.38-4.349 2.67-7.614 6.15-7.614 1.484 0 2.983.673 3.988 1.618Z" clip-rule=evenodd></path></svg></span>喜欢</button><button type=button class="Button Button--plain Button--withIcon Button--withLabel"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="Zi Zi--Star Button-zi" fill=currentColor><path d="M10.484 3.307c.673-1.168 2.358-1.168 3.032 0l2.377 4.122a.25.25 0 0 0 .165.12l4.655.987c1.319.28 1.84 1.882.937 2.884l-3.186 3.535a.25.25 0 0 0-.063.193l.5 4.733c.142 1.34-1.222 2.33-2.453 1.782l-4.346-1.938a.25.25 0 0 0-.204 0l-4.346 1.938c-1.231.549-2.595-.442-2.453-1.782l.5-4.733a.25.25 0 0 0-.064-.193L2.35 11.42c-.903-1.002-.382-2.604.937-2.884l4.655-.987a.25.25 0 0 0 .164-.12l2.378-4.122Z"></path></svg></span>收藏</button><button type=button class="Button ContentItem-action Button--plain Button--withIcon Button--withLabel"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="Zi Zi--Deliver Button-zi" fill=currentColor><g fill-rule=evenodd clip-rule=evenodd><path d="M7.821 12a.75.75 0 0 1 .75-.75h6.857a.75.75 0 0 1 0 1.5H8.571a.75.75 0 0 1-.75-.75ZM8.965 8a.75.75 0 0 1 .75-.75h4.571a.75.75 0 0 1 0 1.5H9.715a.75.75 0 0 1-.75-.75Z"></path><path d="M7.527 3.15a2.35 2.35 0 0 0-2.309 1.91L3.165 15.84a.85.85 0 0 0-.015.16v2.5a2.35 2.35 0 0 0 2.35 2.35h13a2.35 2.35 0 0 0 2.35-2.35V16a.848.848 0 0 0-.015-.16L18.78 5.06a2.35 2.35 0 0 0-2.308-1.91H7.527Zm0 1.7a.65.65 0 0 0-.639.528l-1.88 9.872h13.984l-1.88-9.872a.65.65 0 0 0-.64-.528H7.528Z"></path></g></svg></span>申请转载</button><div class=Post-ActionMenuButton><div class=Popover><div id=Popover3-toggle aria-haspopup=true aria-expanded=false aria-owns=Popover3-content><button type=button class="Button Button--plain Button--withIcon Button--iconOnly"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="Zi Zi--Dots Button-zi" fill=currentColor><path d="M5.34 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM13.665 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM21.99 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0Z"></path></svg></span></button></div></div></div></div></div></div></article><div class="Post-Sub Post-NormalSub"><div style=overflow:unset data-za-detail-view-path-module=CommentList data-za-extra-module={}><div class="Comments-container css-plbgu"><div class=css-79elbk><div><div class=css-1fo89v5><img class="Avatar css-1oi6kgx" src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50"><rect fill-opacity="0"/></svg>' srcset style="background-blend-mode:normal!important;background-clip:content-box!important;background-position:50% 50%!important;background-color:rgb(255,255,255)!important;background-image:var(--sf-img-5)!important;background-size:100% 100%!important;background-origin:content-box!important;background-repeat:no-repeat!important" sizes><div class=css-x0pxoz><div class=css-i6bazn><div class=css-0><div class="InputLike css-ip4bff Editable"><div style=min-height:38px class="Dropzone Editable-content RichText RichText--editable RichText--clearBoth ztext"><div class=DraftEditor-root><div class=public-DraftEditorPlaceholder-root><div class=public-DraftEditorPlaceholder-inner id=placeholder-dqnud style=white-space:pre-wrap>写下你的评论...</div></div><div class=DraftEditor-editorContainer><div aria-describedby=placeholder-dqnud class="notranslate public-DraftEditor-content" spellcheck=true style=outline:none;user-select:text;white-space:pre-wrap;overflow-wrap:break-word tabindex=0 role=textbox contenteditable=true><div data-contents=true><div class=Editable-unstyled data-block=true data-editor=dqnud data-offset-key=e1kmu-0-0><div data-offset-key=e1kmu-0-0 class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr"><span data-offset-key=e1kmu-0-0><br data-text=true></span></div></div></div></div></div></div></div><div></div><input multiple type=file style=display:none accept=image/webp,image/jpg,image/jpeg,image/png,image/gif value></div></div></div></div></div></div><div class=css-z07uxh><div class=css-we6n55><div class=css-vpssrj><div class=css-1k10w8f>3 条评论</div></div><div class=css-59erns></div><div class=css-1hnxfhy><div class=css-gjiv4z>默认</div><div class=css-1v9si9f>最新</div></div></div><div class=css-840pn3><div class=css-1frn93x><div><div class=css-194v73m><div class=css-1jll2aj><div class=css-1gomreu><a href=https://www.zhihu.com/people/dcd384460dae3683f42e0a6cb75ca88f target=_blank class=css-y06ck6><img class="Avatar css-1s1htbw" src= srcset alt=Antihero loading=lazy sizes></a></div></div><div class=css-14nvvry><div class=css-1besdh8><div class=css-swj9d4><div class=css-1tww9qq><div class=css-1gomreu><a href=https://www.zhihu.com/people/dcd384460dae3683f42e0a6cb75ca88f target=_blank class=css-1rd0h6f>Antihero</a></div><div class=css-1qe0v6x><div class=css-1ssbn0c></div></div></div></div><svg width=16 height=16 viewBox="0 0 24 24" class="ZDI ZDI--Dots24 css-zgte1c" fill=currentColor><path d="M5.34 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM13.665 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM21.99 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0Z"></path></svg></div><div class="CommentContent css-1ygdre8"><p>QDirModel 不用载入数据</p></div><div class=css-dbby2p><div class=css-82fsyv><div class=css-12cl38p>2021-03-03</div></div><div class=css-18opwoy><button type=button class="Button css-1o56bgb"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="ZDI ZDI--ChatBubbleFill24 css-15ro776" fill=currentColor><path fill-rule=evenodd d="M12 2.75a9.25 9.25 0 1 0 4.737 17.197l2.643.817a1 1 0 0 0 1.25-1.25l-.8-2.588A9.25 9.25 0 0 0 12 2.75Z" clip-rule=evenodd></path></svg></span>回复</button><button style=transform:none type=button class="Button css-h1yvwn"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="ZDI ZDI--ThumbFill24 css-15ro776" fill=currentColor><path d="M8.5 4.078c0-1.834 1.986-2.979 3.573-2.06a4.826 4.826 0 0 1 2.379 4.71l-.114 1.022h3.581c2.53 0 4.334 2.454 3.58 4.868l-1.823 5.833a3.784 3.784 0 0 1-3.848 2.64c-2.372-.147-6.042-.341-8.828-.341H4.5A1.75 1.75 0 0 1 2.75 19V9.5c0-.967.784-1.75 1.75-1.75h.637a3.418 3.418 0 0 0 3.19-2.191c.115-.296.173-.611.173-.928v-.553Z"></path></svg></span>赞</button></div></div></div></div></div><div><div class=css-194v73m><div class=css-1jll2aj><div class=css-1gomreu><a href=https://www.zhihu.com/people/fff9914877e88d688121e0ed7328278a target=_blank class=css-y06ck6><img class="Avatar css-1s1htbw" src= srcset alt=一千零一夜的价格 loading=lazy sizes></a></div></div><div class=css-14nvvry><div class=css-1besdh8><div class=css-swj9d4><div class=css-1tww9qq><div class=css-1gomreu><a href=https://www.zhihu.com/people/fff9914877e88d688121e0ed7328278a target=_blank class=css-1rd0h6f>一千零一夜的价格</a></div><div class=css-1qe0v6x><div class=css-1ssbn0c></div></div></div></div><svg width=16 height=16 viewBox="0 0 24 24" class="ZDI ZDI--Dots24 css-zgte1c" fill=currentColor><path d="M5.34 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM13.665 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM21.99 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0Z"></path></svg></div><div class="CommentContent css-1ygdre8"><p>打卡<div class="comment_sticker css-h7rrn2"><img alt src= data-rawwidth=120 data-rawheight=120 data-original=https://pic4.zhimg.com/v2-b789d8e597d920061dcd4efb585cd343.gif loading=lazy class=css-8z95sv></div></div><div class=css-dbby2p><div class=css-82fsyv><div class=css-12cl38p>2020-09-02</div></div><div class=css-18opwoy><button type=button class="Button css-1o56bgb"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="ZDI ZDI--ChatBubbleFill24 css-15ro776" fill=currentColor><path fill-rule=evenodd d="M12 2.75a9.25 9.25 0 1 0 4.737 17.197l2.643.817a1 1 0 0 0 1.25-1.25l-.8-2.588A9.25 9.25 0 0 0 12 2.75Z" clip-rule=evenodd></path></svg></span>回复</button><button style=transform:none type=button class="Button css-h1yvwn"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="ZDI ZDI--ThumbFill24 css-15ro776" fill=currentColor><path d="M8.5 4.078c0-1.834 1.986-2.979 3.573-2.06a4.826 4.826 0 0 1 2.379 4.71l-.114 1.022h3.581c2.53 0 4.334 2.454 3.58 4.868l-1.823 5.833a3.784 3.784 0 0 1-3.848 2.64c-2.372-.147-6.042-.341-8.828-.341H4.5A1.75 1.75 0 0 1 2.75 19V9.5c0-.967.784-1.75 1.75-1.75h.637a3.418 3.418 0 0 0 3.19-2.191c.115-.296.173-.611.173-.928v-.553Z"></path></svg></span>赞</button></div></div></div></div></div><div><div class=css-194v73m><div class=css-1jll2aj><div class=css-1gomreu><a href=https://www.zhihu.com/people/3ef7e80e9d94eabc12c24ef6496f4d50 target=_blank class=css-y06ck6><img class="Avatar css-1s1htbw" src= srcset alt=TT要学习 loading=lazy sizes></a></div></div><div class=css-14nvvry><div class=css-1besdh8><div class=css-swj9d4><div class=css-1tww9qq><div class=css-1gomreu><a href=https://www.zhihu.com/people/3ef7e80e9d94eabc12c24ef6496f4d50 target=_blank class=css-1rd0h6f>TT要学习</a></div><div class=css-1qe0v6x><div class=css-1ssbn0c></div></div></div></div><svg width=16 height=16 viewBox="0 0 24 24" class="ZDI ZDI--Dots24 css-zgte1c" fill=currentColor><path d="M5.34 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM13.665 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0ZM21.99 12a1.665 1.665 0 1 1-3.33 0 1.665 1.665 0 0 1 3.33 0Z"></path></svg></div><div class="CommentContent css-1ygdre8"><p>感谢，解决了我的困惑</p></div><div class=css-dbby2p><div class=css-82fsyv><div class=css-12cl38p>2020-04-28</div></div><div class=css-18opwoy><button type=button class="Button css-1o56bgb"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="ZDI ZDI--ChatBubbleFill24 css-15ro776" fill=currentColor><path fill-rule=evenodd d="M12 2.75a9.25 9.25 0 1 0 4.737 17.197l2.643.817a1 1 0 0 0 1.25-1.25l-.8-2.588A9.25 9.25 0 0 0 12 2.75Z" clip-rule=evenodd></path></svg></span>回复</button><button style=transform:none type=button class="Button css-h1yvwn"><span style=display:inline-flex;align-items:center>​<svg width=1.2em height=1.2em viewBox="0 0 24 24" class="ZDI ZDI--ThumbFill24 css-15ro776" fill=currentColor><path d="M8.5 4.078c0-1.834 1.986-2.979 3.573-2.06a4.826 4.826 0 0 1 2.379 4.71l-.114 1.022h3.581c2.53 0 4.334 2.454 3.58 4.868l-1.823 5.833a3.784 3.784 0 0 1-3.848 2.64c-2.372-.147-6.042-.341-8.828-.341H4.5A1.75 1.75 0 0 1 2.75 19V9.5c0-.967.784-1.75 1.75-1.75h.637a3.418 3.418 0 0 0 3.19-2.191c.115-.296.173-.611.173-.928v-.553Z"></path></svg></span>赞</button></div></div></div></div></div><div></div></div></div></div></div></div></div><div class=PostIndex-Contributions data-za-detail-view-path-module=ColumnList data-za-detail-view-path-module_name=文章被以下专栏收录 data-za-extra-module={}><h3 class=BlockTitle>文章被以下专栏收录</h3><ul><div class="ContentItem Column-ColumnItem"><div class=ContentItem-main><div class=ContentItem-image><a class=ColumnLink href=https://www.zhihu.com/column/pyqt5><div class=css-1gomreu><img class="Avatar css-1any501" src="" srcset alt=快速掌握PyQt5 sizes></div></a></div><div class=ContentItem-head><h2 class=ContentItem-title><span><a class="ColumnLink ColumnItem-Title" href=https://www.zhihu.com/column/pyqt5><div class=css-1gomreu>快速掌握PyQt5</div></a></span></h2><div class=ContentItem-meta>带你快速学会使用PyQt5</div></div></div></div></ul></div><div role=complementary aria-label=推荐阅读 class=Recommendations-Main style=width:1853px><h3 class="BlockTitle Recommendations-BlockTitle">推荐阅读</h3><ul class=Recommendations-List><button class="PagingButton PagingButton-Previous" disabled data-za-detail-view-path-module=Unknown data-za-detail-view-path-module_name=推荐阅读 data-za-extra-module={}><svg width=40 height=40 viewBox="0 0 24 24" fill=#d3d3d3 class="Zi Zi--ArrowLeft"><path fill-rule=evenodd d="m10.752 12 4.025-3.78a.684.684 0 0 0 0-1.01.796.796 0 0 0-1.075 0l-4.42 4.15a.866.866 0 0 0 0 1.28l4.42 4.15a.796.796 0 0 0 1.075 0 .684.684 0 0 0 0-1.01L10.752 12Z" clip-rule=evenodd></path></svg></button><a href=https://zhuanlan.zhihu.com/p/29882089 class=PostItem><div><img src="" srcset class=PostItem-TitleImage alt=Python数据分析及可视化实例之可视化图表应用简介 sizes><h1 class=PostItem-Title>Python数据分析及可视化实例之可视化图表应用简介</h1><div class=PostItem-Footer><span>civilpy</span><span class=PostItem-FooterTitle></span></div></div></a><a href=https://zhuanlan.zhihu.com/p/79484631 class=PostItem><div><h1 class=PostItem-Title>聊聊何为图数据库和图数据库的小知识</h1><p class=PostItem-Summary>图数据库 - 维基百科：在计算机科学中，图数据库（英语：graph database，GDB）是一个使用图结构进行语义查询的数据库，它使用节点、边和属性来表示和存储数据。该系统的关键概念是图，它直…<div class=PostItem-Footer><span>NebulaGraph</span><span class=PostItem-FooterTitle></span></div></div></a><a href=https://zhuanlan.zhihu.com/p/129607002 class=PostItem><div><h1 class=PostItem-Title>Python怎么画直方图？Matplotlib数据可视化005：直方图</h1><p class=PostItem-Summary>前文回看： 【Python菜鸟进阶大神】Matplotlib数据可视化001：基础API汇总&amp;amp;散点图 【Python菜鸟进阶大神】Matplotlib数据可视化002：折线图 【Python菜鸟进阶大神】Matplotlib数据可视…<div class=PostItem-Footer><span>Yang</span><span class=PostItem-FooterTitle></span></div></div></a><a href=https://zhuanlan.zhihu.com/p/514361744 class=PostItem><div><img src="" srcset class=PostItem-TitleImage alt=王敏捷：图算法如何高效表达图计算？DGL图学习平台YYDS！ sizes><h1 class=PostItem-Title>王敏捷：图算法如何高效表达图计算？DGL图学习平台YYDS！</h1><div class=PostItem-Footer><span>DataF...</span><span class=PostItem-FooterTitle>发表于人工智能算...</span></div></div></a><button class="PagingButton PagingButton-Next" data-za-detail-view-path-module=Unknown data-za-detail-view-path-module_name=推荐阅读 data-za-extra-module={}><svg width=40 height=40 viewBox="0 0 24 24" fill=#d3d3d3 class="Zi Zi--ArrowRight"><path fill-rule=evenodd d="m13.248 12-4.025 3.78a.684.684 0 0 0 0 1.01.796.796 0 0 0 1.075 0l4.42-4.15a.867.867 0 0 0 0-1.28l-4.42-4.15a.796.796 0 0 0-1.075 0 .684.684 0 0 0 0 1.01L13.248 12Z" clip-rule=evenodd></path></svg></button></ul></div></div></div></main><div role=complementary><div class=CornerButtons><div class="CornerAnimayedFlex CornerAnimayedFlex--hidden"><button data-tooltip=回到顶部 data-tooltip-position=left data-tooltip-will-hide-on-click=true aria-label=回到顶部 type=button class="Button CornerButton css-gdd4kf"><svg width=24 height=24 viewBox="0 0 24 24" aria-hidden=true class="Zi Zi--BackToTop" fill=currentColor><path fill-rule=evenodd d="M13.204 3.107a1.75 1.75 0 0 0-2.408 0L3.806 9.73c-1.148 1.088-.378 3.02 1.204 3.02h2.24V20c0 .966.784 1.75 1.75 1.75h6A1.75 1.75 0 0 0 16.75 20v-7.25h2.24c1.582 0 2.353-1.932 1.204-3.02l-6.99-6.623Z" clip-rule=evenodd></path></svg></button></div></div></div></div></div><div><div style=display:none></div></div><div><div><div class=css-8pdeid></div></div></div><div><div><div style=left:-1179px;top:-999px class=Editable-languageSuggestions><div><div class=Popover><label class="Editable-languageSuggestionsInput Input-wrapper"><input autocomplete=off role=combobox aria-expanded=false aria-autocomplete=list aria-activedescendant=AutoComplete7-0 id=Popover6-toggle aria-haspopup=true aria-owns=Popover6-content class=Input placeholder=选择语言 value><svg width=24 height=24 viewBox="0 0 24 24" fill=#afbdcf class="Zi Zi--Select"><path fill-rule=evenodd d="M12.53 3.47a.75.75 0 0 0-1.06 0l-5 5a.75.75 0 0 0 1.06 1.06L12 5.06l4.47 4.47a.75.75 0 1 0 1.06-1.06l-5-5Zm-5 11a.75.75 0 0 0-1.06 1.06l5 5a.75.75 0 0 0 1.06 0l5-5a.75.75 0 1 0-1.06-1.06L12 18.94l-4.47-4.47Z" clip-rule=evenodd></path></svg></label></div></div></div></div></div>